-
Notifications
You must be signed in to change notification settings - Fork 212
Feature: Passwordless Login and Password Reset supports use of email mode
#3525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
7877887
22b6a36
c646e44
bd6d1d0
11be87e
d9ed864
07802f3
c0aedcb
3d27d0b
e49c9be
3cfece1
c02836d
3d79932
892ef8c
076b1ac
b0ca814
3c05026
36e1b20
3e9e385
abff98d
fe0a623
5f31e30
bc6f621
c766b59
f4852df
12a235d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,6 @@ import { | |
| isOriginTrusted, | ||
| onClient, | ||
| getDefaultCookieAttributes, | ||
| isAbsoluteUrl, | ||
| stringToBase64, | ||
| extractCustomParameters | ||
| } from '../utils' | ||
|
|
@@ -55,6 +54,7 @@ interface AuthConfig extends ApiClientConfigParams { | |
| refreshTokenRegisteredCookieTTL?: number | ||
| refreshTokenGuestCookieTTL?: number | ||
| hybridAuthEnabled?: boolean | ||
| locale: string | ||
| } | ||
|
|
||
| interface JWTHeaders { | ||
|
|
@@ -95,7 +95,7 @@ type AuthorizeIDPParams = { | |
| type AuthorizePasswordlessParams = { | ||
| callbackURI?: string | ||
| userid: string | ||
| mode?: string | ||
| mode?: 'email' | 'callback' | ||
| } | ||
|
|
||
| type GetPasswordLessAccessTokenParams = { | ||
|
|
@@ -273,6 +273,7 @@ class Auth { | |
| | undefined | ||
|
|
||
| private hybridAuthEnabled: boolean | ||
| private locale: string | ||
|
|
||
| constructor(config: AuthConfig) { | ||
| // Special proxy endpoint for injecting SLAS private client secret. | ||
|
|
@@ -366,10 +367,11 @@ class Auth { | |
|
|
||
| this.isPrivate = !!this.clientSecret | ||
|
|
||
| const passwordlessLoginCallbackURI = config.passwordlessLoginCallbackURI | ||
| this.passwordlessLoginCallbackURI = passwordlessLoginCallbackURI || '' | ||
| this.passwordlessLoginCallbackURI = config.passwordlessLoginCallbackURI || '' | ||
|
|
||
| this.hybridAuthEnabled = config.hybridAuthEnabled || false | ||
|
|
||
| this.locale = config.locale | ||
| } | ||
|
|
||
| get(name: AuthDataKeys) { | ||
|
|
@@ -1269,19 +1271,23 @@ class Auth { | |
| */ | ||
| async authorizePasswordless(parameters: AuthorizePasswordlessParams) { | ||
| const usid = this.get('usid') | ||
| // Default to 'callback' mode for backward compatibility as older versions of the template-retail-react-app | ||
| // do not pass the mode parameter. Newer versions should explicitly pass the mode. | ||
| const mode = parameters.mode || 'callback' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The upcoming release is gonna be breaking change version. If you want to change the default, now is the time
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure you document this behavior somewhere to make it clear
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will make sure it's documented in the dev docs |
||
| const callbackURI = parameters.callbackURI || this.passwordlessLoginCallbackURI | ||
| const finalMode = callbackURI ? 'callback' : parameters.mode || 'sms' | ||
| const locale = this.locale | ||
|
|
||
| const res = await helpers.authorizePasswordless({ | ||
| slasClient: this.client, | ||
| credentials: { | ||
| clientSecret: this.clientSecret | ||
| }, | ||
| parameters: { | ||
| ...(callbackURI && {callbackURI: callbackURI}), | ||
| ...(callbackURI && {callbackURI}), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we omit this if mode === email ?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ...(usid && {usid}), | ||
| ...(locale && {locale}), | ||
|
||
| userid: parameters.userid, | ||
| mode: finalMode | ||
| mode | ||
| } | ||
| }) | ||
| if (res && res.status !== 200) { | ||
|
|
||



Uh oh!
There was an error while loading. Please reload this page.