Skip to content

Commit 3024852

Browse files
authored
[auth] Make browser-based login the default (#3746)
1 parent ecf58ab commit 3024852

4 files changed

Lines changed: 37 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ This is the log of notable changes to EAS CLI and related packages.
66

77
### 🛠 Breaking changes
88

9+
- [eas-cli] Make browser-based authentication the default for `eas login`. Use `--no-browser` for CLI-based login. ([#3746](https://github.com/expo/eas-cli/pull/3746) by [@byronkarlen](https://github.com/byronkarlen))
10+
911
### 🎉 New features
1012

1113
- [eas-cli] Allow command `observe:routes` to filter results to specific route names. ([#3744](https://github.com/expo/eas-cli/pull/3744) by [@douglowder](https://github.com/douglowder))

packages/eas-cli/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ log in with your Expo account
177177

178178
```
179179
USAGE
180-
$ eas account:login [-s] [-b]
180+
$ eas account:login [-s] [-b | --no-browser]
181181
182182
FLAGS
183-
-b, --browser Login with your browser
184-
-s, --sso Login with SSO
183+
-b, --[no-]browser Log in with your browser (default; use --no-browser for CLI-based login)
184+
-s, --sso Log in with SSO
185185
186186
DESCRIPTION
187187
log in with your Expo account
@@ -1811,11 +1811,11 @@ log in with your Expo account
18111811

18121812
```
18131813
USAGE
1814-
$ eas login [-s] [-b]
1814+
$ eas login [-s] [-b | --no-browser]
18151815
18161816
FLAGS
1817-
-b, --browser Login with your browser
1818-
-s, --sso Login with SSO
1817+
-b, --[no-]browser Log in with your browser (default; use --no-browser for CLI-based login)
1818+
-s, --sso Log in with SSO
18191819
18201820
DESCRIPTION
18211821
log in with your Expo account

packages/eas-cli/src/commands/account/login.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ export default class AccountLogin extends EasCommand {
1313
static override flags = {
1414
// can pass either --sso or -s
1515
sso: Flags.boolean({
16-
description: 'Login with SSO',
16+
description: 'Log in with SSO',
1717
char: 's',
1818
default: false,
1919
}),
2020
browser: Flags.boolean({
21-
description: 'Login with your browser',
21+
description: 'Log in with your browser (default; use --no-browser for CLI-based login)',
2222
char: 'b',
23-
default: false,
23+
default: true,
24+
allowNo: true,
2425
}),
2526
};
2627

packages/eas-cli/src/user/__tests__/SessionManager-test.ts

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ describe(SessionManager, () => {
294294
username: 'USERNAME',
295295
});
296296

297-
await sessionManager.showLoginPromptAsync();
297+
await sessionManager.showLoginPromptAsync({ browser: false });
298298

299299
expect(sessionManagerRetryUsernamePasswordAuthWithOTPAsyncSpy).toHaveBeenCalledWith(
300300
'hello',
@@ -313,7 +313,27 @@ describe(SessionManager, () => {
313313
);
314314
});
315315

316-
it('calls regular login if the sso flag is false', async () => {
316+
it('calls regular login by default', async () => {
317+
jest
318+
.mocked(promptAsync)
319+
.mockImplementationOnce(async () => ({ username: 'USERNAME', password: 'PASSWORD' }))
320+
.mockImplementation(() => {
321+
throw new Error("shouldn't happen");
322+
});
323+
324+
jest.mocked(fetchSessionSecretAndUserAsync).mockResolvedValue({
325+
sessionSecret: 'SESSION_SECRET',
326+
id: 'USER_ID',
327+
username: 'USERNAME',
328+
});
329+
const sessionManager = new SessionManager(analytics);
330+
331+
await sessionManager.showLoginPromptAsync();
332+
333+
expect(fetchSessionSecretAndUserAsync).toHaveBeenCalled();
334+
});
335+
336+
it('calls regular login when browser is false', async () => {
317337
jest
318338
.mocked(promptAsync)
319339
.mockImplementationOnce(async () => ({ username: 'USERNAME', password: 'PASSWORD' }))
@@ -323,12 +343,11 @@ describe(SessionManager, () => {
323343

324344
const sessionManager = new SessionManager(analytics);
325345

326-
// Regular login
327-
await sessionManager.showLoginPromptAsync({ sso: false });
346+
await sessionManager.showLoginPromptAsync({ browser: false });
328347
expect(fetchSessionSecretAndUserAsync).toHaveBeenCalled();
329348
});
330349

331-
it('calls regular login if the sso flag is undefined', async () => {
350+
it('calls regular login if the sso flag is false and browser is false', async () => {
332351
jest
333352
.mocked(promptAsync)
334353
.mockImplementationOnce(async () => ({ username: 'USERNAME', password: 'PASSWORD' }))
@@ -338,8 +357,7 @@ describe(SessionManager, () => {
338357

339358
const sessionManager = new SessionManager(analytics);
340359

341-
// Regular login
342-
await sessionManager.showLoginPromptAsync({ sso: undefined });
360+
await sessionManager.showLoginPromptAsync({ sso: false, browser: false });
343361
expect(fetchSessionSecretAndUserAsync).toHaveBeenCalled();
344362
});
345363

0 commit comments

Comments
 (0)