Skip to content

Commit 20473cd

Browse files
authored
Merge pull request #18940 from mozilla/FXA-11730
feat(oauth): redirect on prompt=none and return_on_error=false
2 parents fa20324 + b1dcab4 commit 20473cd

3 files changed

Lines changed: 22 additions & 251 deletions

File tree

packages/functional-tests/tests/oauth/oauthPromptNone.spec.ts

Lines changed: 0 additions & 240 deletions
This file was deleted.

packages/functional-tests/tests/react-conversion/oauthPromptNone.spec.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ test.describe('severity-1 #smoke', () => {
1717
});
1818

1919
test.describe('oauth prompt none', () => {
20-
test('fails if no user logged in', async ({
20+
test('redirects to signup if no user logged in', async ({
2121
page,
2222
target,
23-
pages: { relier },
23+
pages: { relier, signup },
2424
testAccountTracker,
2525
}) => {
2626
const { email } = testAccountTracker.generateAccountDetails();
@@ -32,9 +32,8 @@ test.describe('severity-1 #smoke', () => {
3232
await page.goto(`${target.relierUrl}/?${query.toString()}`);
3333
await relier.signInPromptNone();
3434

35-
//Verify error message
36-
await page.waitForURL(/authorization/);
37-
await expect(page.getByText('User is not signed in')).toBeVisible();
35+
await page.waitForURL(/oauth/);
36+
await expect(signup.signupFormHeading).toBeVisible();
3837
});
3938

4039
test('fails RP that is not allowed', async ({
@@ -93,10 +92,10 @@ test.describe('severity-1 #smoke', () => {
9392
).toBeVisible();
9493
});
9594

96-
test('fails if session is no longer valid', async ({
95+
test('redirects if session is no longer valid', async ({
9796
page,
9897
target,
99-
pages: { relier, settings, signin },
98+
pages: { relier, settings, signin, signup },
10099
testAccountTracker,
101100
}) => {
102101
const credentials = await testAccountTracker.signUp();
@@ -120,9 +119,8 @@ test.describe('severity-1 #smoke', () => {
120119
await page.goto(`${target.relierUrl}/?${query.toString()}`);
121120
await relier.signInPromptNone();
122121

123-
// Verify error message
124-
await page.waitForURL(/authorization/);
125-
await expect(page.getByText('User is not signed in')).toBeVisible();
122+
await page.waitForURL(/oauth/);
123+
await expect(signup.signupFormHeading).toBeVisible();
126124
});
127125

128126
test('fails if account is not verified', async ({

packages/fxa-settings/src/pages/Authorization/container.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ import { currentAccount } from '../../lib/cache';
1818
import { useFinishOAuthFlowHandler } from '../../lib/oauth/hooks';
1919
import OAuthDataError from '../../components/OAuthDataError';
2020
import { cachedSignIn, handleNavigation } from '../Signin/utils';
21-
import { AuthError, OAuthError } from '../../lib/oauth/oauth-errors';
21+
import {
22+
AuthError,
23+
OAUTH_ERRORS,
24+
OAuthError,
25+
} from '../../lib/oauth/oauth-errors';
2226
import { AuthUiErrors } from '../../lib/auth-errors/auth-errors';
2327
import { hardNavigate } from 'fxa-react/lib/utils';
2428
import { useNavigateWithQuery } from '../../lib/hooks/useNavigateWithQuery';
@@ -120,13 +124,22 @@ const AuthorizationContainer = ({
120124
return;
121125
}
122126

127+
if (
128+
!(integration as OAuthWebIntegration).returnOnError() &&
129+
err.errno === OAUTH_ERRORS['PROMPT_NONE_NOT_SIGNED_IN'].errno
130+
) {
131+
navigateWithQuery('/oauth');
132+
return;
133+
}
134+
123135
setOauthError(err);
124136
}
125137
}, [
126138
authClient,
127139
finishOAuthFlowHandler,
128140
integration,
129141
location.search,
142+
navigateWithQuery,
130143
session,
131144
]);
132145

0 commit comments

Comments
 (0)