This is an automated email from the ASF dual-hosted git repository. msciabarra pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/openserverless-vscode-extension.git
commit 7ac8d52b0c4baac5e267bb7a17d4ad3133aad889 Author: William Grienti <[email protected]> AuthorDate: Sat Mar 16 19:10:48 2024 +0100 login fixes --- src/extension.ts | 23 ++++++++++++++++++----- src/login/LoginPanel.ts | 4 ++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 09f56f9..aaadbdf 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -4,6 +4,8 @@ import { LoginPanel } from './login/LoginPanel'; import { CliCommands } from './enumerators'; import * as fs from "fs"; import * as os from "os"; +import { exec, execSync } from 'child_process'; +import { stderr } from 'process'; let context: vscode.ExtensionContext; @@ -15,7 +17,10 @@ export async function activate(ctx: vscode.ExtensionContext) { Object.entries(CliCommands).forEach(([name, command]) => context.subscriptions.push(vscode.commands.registerCommand(`nuvolaris.${name.toLowerCase()}`, () => { - if (!loggedIn) LoginPanel.render(handleLogin, context.extensionUri); + if (!loggedIn) { + LoginPanel.render(handleLogin, context.extensionUri); + return; + } launchTerminal(command); } ))); @@ -39,14 +44,22 @@ function isLoggedIn() { } function handleLogin(username: string, password: string, apiHost: string) { + const loginOutput = vscode.window.createOutputChannel('Nuvolaris Login'); + loginOutput.show(); try { - launchTerminal(`nuv -login ${apiHost} ${username} ${password}`); - } catch (error) { - printError(error); + loginOutput.appendLine('Launching login script...'); + const execLogin = execSync(`nuv -login ${apiHost.endsWith('/') ? apiHost.slice(0, -1) : apiHost} ${username}`, { + env: {...process.env, NUV_PASSWORD: password} + }); + loginOutput.appendLine(execLogin.toString()); + + } catch (error: any) { + loginOutput.appendLine(error); throw error; } } + function launchTerminal(command: string): void { try { // If a terminal named "Nuvolaris" already exists, launch the command inside that one. @@ -61,4 +74,4 @@ function launchTerminal(command: string): void { function printError(error: any) { return vscode.window.showErrorMessage("Error occurred", error.toString()); -} \ No newline at end of file +} diff --git a/src/login/LoginPanel.ts b/src/login/LoginPanel.ts index 51ed482..225f267 100644 --- a/src/login/LoginPanel.ts +++ b/src/login/LoginPanel.ts @@ -118,7 +118,7 @@ export class LoginPanel { <form class="login-form" id="login-form"> <input type="text" id="username-input" placeholder="Username"> <input type="password" id="password-input" placeholder="Password"> - <input type="text" id="api-host-input" placeholder="API Host URL" value="https://nuvolaris.dev/"> + <input type="text" id="api-host-input" placeholder="API Host URL" value="https://nuvolaris.dev"> <vscode-button id="login-button" type="submit" > L O G I N </vscode-button> </form> </div> @@ -152,4 +152,4 @@ export class LoginPanel { } } } -} \ No newline at end of file +}
