Skip to content

Commit

Permalink
feat<Auth>: Allow sending login_hint, lang and nonce on signInWithRed…
Browse files Browse the repository at this point in the history
…irects (aws-amplify#8951)
  • Loading branch information
Alevale committed Dec 18, 2024
1 parent ec2ff53 commit 6715b79
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/auth/src/providers/cognito/apis/signInWithRedirect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ export async function signInWithRedirect(
provider,
customState: input?.customState,
preferPrivateSession: input?.options?.preferPrivateSession,
loginHint: input?.options?.loginHint,
lang: input?.options?.lang,
nonce: input?.options?.nonce,
});
}

Expand All @@ -66,12 +69,18 @@ const oauthSignIn = async ({
clientId,
customState,
preferPrivateSession,
loginHint,
lang,
nonce,
}: {
oauthConfig: OAuthConfig;
provider: string;
clientId: string;
customState?: string;
preferPrivateSession?: boolean;
loginHint?: string;
lang?: string;
nonce?: string;
}) => {
const { domain, redirectSignIn, responseType, scopes } = oauthConfig;
const randomState = generateState();
Expand Down Expand Up @@ -99,6 +108,10 @@ const oauthSignIn = async ({
client_id: clientId,
identity_provider: provider,
scope: scopes.join(' '),
// eslint-disable-next-line camelcase
...(loginHint && { login_hint: loginHint }),
...(lang && { lang }),
...(nonce && { nonce }),
state,
...(responseType === 'code' && {
code_challenge: toCodeChallenge(),
Expand Down
3 changes: 3 additions & 0 deletions packages/auth/src/types/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export interface AuthSignInWithRedirectInput {
* On all other platforms, this flag is ignored.
*/
preferPrivateSession?: boolean;
loginHint?: string;
lang?: string;
nonce?: string;
};
}

Expand Down

0 comments on commit 6715b79

Please sign in to comment.