Merge pull request #2057 from balena-io/allow-alternative-signups

login: sign up at the configured balena instance
This commit is contained in:
bulldozer-balena[bot] 2020-10-07 16:27:08 +00:00 committed by GitHub
commit 873eb1fc59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -132,7 +132,7 @@ export default class LoginCmd extends Command {
console.log(messages.balenaAsciiArt); console.log(messages.balenaAsciiArt);
console.log(`\nLogging in to ${balenaUrl}`); console.log(`\nLogging in to ${balenaUrl}`);
await this.doLogin(options, params.token); await this.doLogin(options, balenaUrl, params.token);
const username = await balena.auth.whoami(); const username = await balena.auth.whoami();
@ -146,7 +146,11 @@ Find out about the available commands by running:
${messages.reachingOut}`); ${messages.reachingOut}`);
} }
async doLogin(loginOptions: FlagsDef, token?: string): Promise<void> { async doLogin(
loginOptions: FlagsDef,
balenaUrl: string = 'balena-cloud.com',
token?: string,
): Promise<void> {
// Token // Token
if (loginOptions.token) { if (loginOptions.token) {
if (!token) { if (!token) {
@ -178,8 +182,8 @@ ${messages.reachingOut}`);
// User had not selected login preference, prompt interactively // User had not selected login preference, prompt interactively
const loginType = await patterns.askLoginType(); const loginType = await patterns.askLoginType();
if (loginType === 'register') { if (loginType === 'register') {
const signupUrl = 'https://dashboard.balena-cloud.com/signup';
const open = await import('open'); const open = await import('open');
const signupUrl = `https://dashboard.${balenaUrl}/signup`;
open(signupUrl, { wait: false }); open(signupUrl, { wait: false });
throw new ExpectedError(`Please sign up at ${signupUrl}`); throw new ExpectedError(`Please sign up at ${signupUrl}`);
} }