-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Auth): Allow sending login_hint, lang and nonce on signInWithRed…
…irects (#14089) * feat(Auth): Allow sending login_hint, lang and nonce on signInWithRedirects (#8951) * chore(auth): Use the cognito languages as suggestions and add docs for parameters
- Loading branch information
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -295,6 +295,7 @@ describe('signInWithRedirect', () => { | |
); | ||
expect(mockHandleFailure).toHaveBeenCalledWith(expectedError); | ||
}); | ||
|
||
it('should not set the Oauth flag on non-browser environments', async () => { | ||
const mockOpenAuthSessionResult = { | ||
type: 'success', | ||
|
@@ -308,6 +309,28 @@ describe('signInWithRedirect', () => { | |
|
||
expect(oAuthStore.storeOAuthInFlight).toHaveBeenCalledTimes(0); | ||
}); | ||
|
||
it('should send the login_hint, lang and nonce in the query string if provided', async () => { | ||
await signInWithRedirect({ | ||
provider: 'Google', | ||
options: { | ||
loginHint: '[email protected]', | ||
lang: 'en', | ||
nonce: '88388838883', | ||
}, | ||
}); | ||
|
||
const [oauthUrl, redirectSignIn, preferPrivateSession] = | ||
mockOpenAuthSession.mock.calls[0]; | ||
|
||
expect(oauthUrl).toStrictEqual( | ||
'https://oauth.domain.com/oauth2/authorize?redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F&response_type=code&client_id=userPoolClientId&identity_provider=Google&scope=phone%20email%20openid%20profile%20aws.cognito.signin.user.admin&login_hint=someone%40gmail.com&lang=en&nonce=88388838883&state=oauth_state&code_challenge=code_challenge&code_challenge_method=S256', | ||
); | ||
expect(redirectSignIn).toEqual( | ||
mockAuthConfigWithOAuth.Auth.Cognito.loginWith.oauth.redirectSignIn, | ||
); | ||
expect(preferPrivateSession).toBeUndefined(); | ||
}); | ||
}); | ||
|
||
describe('errors', () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters