Skip to content

Commit ca1a001

Browse files
authored
chore(login): deprecate password-based auth (#4877)
1 parent f090194 commit ca1a001

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

packages/@ionic/cli/src/commands/login.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,34 @@ export class LoginCommand extends Command implements CommandPreRun {
1515
type: 'global',
1616
summary: 'Log in to Ionic',
1717
description: `
18-
Authenticate with Ionic and retrieve a user token, which is stored in the CLI config. The most secure way to log in is running ${input('ionic login')} without arguments, which will open a browser where you can submit your credentials.
18+
Authenticate with Ionic and retrieve a user token, which is stored in the CLI config. Running ${input('ionic login')} will open a browser where you can submit your credentials.
1919
20-
If the ${input('IONIC_TOKEN')} environment variable is set, the CLI will automatically authenticate you. To retrieve your user token, first use ${input('ionic login <email> <password>')} to log in, then use ${input('ionic config get -g tokens.user')} to print the token. (${strong('Note')}: Tokens retrieved from the browser login are short-lived and not recommended for use with ${input('IONIC_TOKEN')}.)
21-
22-
${input('ionic login')} will also accept ${input('password')} through stdin, e.g.: ${input('echo "<password>" | ionic login <email>')}.
20+
If the ${input('IONIC_TOKEN')} environment variable is set, the CLI will automatically authenticate you. Use the Dashboard to generate a Personal Access Token.
2321
2422
If you need to create an Ionic account, use ${input('ionic signup')} or the Ionic Website[^signup].
2523
26-
You can reset your password in the Dashboard[^reset-password].
27-
2824
If you are having issues logging in, please get in touch with our Support[^support-request].
2925
`,
3026
footnotes: [
3127
{
3228
id: 'signup',
3329
url: 'https://ionicframework.com/signup',
3430
},
35-
{
36-
id: 'reset-password',
37-
url: 'https://dashboard.ionicframework.com/reset-password',
38-
shortUrl: 'https://ion.link/reset-password',
39-
},
4031
{
4132
id: 'support-request',
4233
url: 'https://ion.link/support-request',
4334
},
4435
],
45-
exampleCommands: ['', 'john@example.com', 'hello@example.com secret'],
36+
exampleCommands: [''],
4637
inputs: [
4738
{
4839
name: 'email',
49-
summary: 'Your email address',
40+
summary: 'Your email address (deprecated)',
5041
private: true,
5142
},
5243
{
5344
name: 'password',
54-
summary: 'Your password',
45+
summary: 'Your password (deprecated)',
5546
private: true,
5647
},
5748
],
@@ -74,6 +65,16 @@ If you are having issues logging in, please get in touch with our Support[^suppo
7465
this.env.log.nl();
7566
}
7667

68+
if (!!inputs[0]) {
69+
this.env.log.warn(
70+
'Authenticating using email and password is deprecated. ' +
71+
(this.env.flags.interactive
72+
? `Please run ${input('ionic login')} without arguments to log in.`
73+
: `Please generate a Personal Access Token and set the ${input('IONIC_TOKEN')} environment variable.`)
74+
);
75+
this.env.log.nl();
76+
}
77+
7778
// ask for password only if the user specifies an email
7879
const validateEmail = !!inputs[0];
7980
const askForPassword = inputs[0] && !inputs[1];

packages/@ionic/cli/src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ async function authenticateFromEnvironment(ienv: IonicEnvironment) {
8383
if (ienv.config.get('user.email') !== email) {
8484
debug(`${strong('IONIC_EMAIL')} mismatch with current session--attempting login`);
8585

86+
ienv.log.warn(
87+
'Authenticating using email and password is deprecated. Please generate a Personal Access Token and set the ' +
88+
strong('IONIC_TOKEN') +
89+
' environment variable.'
90+
);
91+
ienv.log.nl();
92+
8693
try {
8794
await ienv.session.login(email, password);
8895
} catch (e) {

0 commit comments

Comments
 (0)