@W-20448811 Shopper can manually enter OTP in login flows#3554
@W-20448811 Shopper can manually enter OTP in login flows#3554hajinsuha1 merged 104 commits intodevelopfrom
Conversation
* Add passwordless login mode configuration with email as default * Update authorizePasswordless to require mode parameter and add locale support * Remove commented out passwordless callbackURI configuration * Remove passwordlessCallbackURI variable and simplify callbackURI condition in authorizePasswordlessLogin * Remove conditional callbackURI spread and add mode parameter to checkout passwordless login * Add buildCallbackURL utility function and conditionally spread callbackURI in passwordless login * Rename buildCallbackURL to buildAbsoluteUrl and make passwordlessLoginCallbackURI optional * update unit tests in template-retail-react-app and fix passwordless mode in login page * make authorizePasswordless backward compatible and add unit tests for commerce-sdk-react * Make passwordlessLoginCallbackURI non-optional with empty string default * update changelog * Use endsWith() to match passwordless login landing path and add test for localized paths
… via pwa-kit-create-app (#3526)
Signed-off-by: Jinsu Ha <91205717+hajinsuha1@users.noreply.github.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This reverts commit d9a6b12.
* Update getPasswordResetToken to default locale to the one in CommerceApiProvider and pass callback_uri and idp_name only when they are defined * Update resetPassword to default hint to cross_device and pass code_verifier only when it is defined pwa-kit-create-app * Update default.js and /_app-config/index.jsx template to use email mode by default for passwordless login and password reset. * Update password reset to use email mode by default. The mode can now be configured via default.js
…n and updating related components. Adjust OTP input fields in the OtpAuth component to reflect the token length from configuration.
* W-20542850 Remove promotion from Shipping Method summary view * add translations
…ly" to "Continue" (#3556) * update passwordless and password reset e2e tests to veirfy mode email is used * Update EXTRA_FEATURES_E2E_RETAIL_APP_HOME to support environment variable configuration * Update mobile e2e tests to verify 'email' mode for passwordless login and password reset requests * update "continue securely" to "continue"
…-enter-otp-in-login-flows-2 Signed-off-by: Jinsu Ha <91205717+hajinsuha1@users.noreply.github.com>
vmarta
left a comment
There was a problem hiding this comment.
Thank you for the detailed PR description btw. Love the comprehensive ways to test the PR.
I'll continue with the PR review. Posting whatever comments I have so far.
|
|
||
| if (!isValidOtpLength) { | ||
| console.warn( | ||
| `Invalid OTP token length: ${tokenLength}. Expected 6 or 8. Defaulting to ${OTP_LENGTH}.` |
There was a problem hiding this comment.
I think it's better if we enforce this 6 or 8 digit requirement somehow in both the user configuration and also in our own code. Currently, it feels like it's not easily known for other developers that there's this requirement.
Perhaps we can use constants or enums to restrict them to either 6 or 8. And add some validations somewhere to make it loud and clear of this requirement.
There was a problem hiding this comment.
@vmarta Makes sense! I've added a validation check to default.js. If the merchant sets an invalid OTP_TOKEN_LENGTH via env vars the app will throw an error
If they update default.js with a value directly that is invalid like:
login: {
// The length of the token for OTP authentication. Used by passwordless login and reset password.
// If the env var `OTP_TOKEN_LENGTH` is set, it will override the config value. Valid values are 6 or 8. Defaults to: 8
tokenLength: 7,
They'll see a console warn when the OtpAuthModal is opened and the value would default to 8
In the docs, I'll mention setting tokenLength via env vars and not recommend setting it directly via default.js
vmarta
left a comment
There was a problem hiding this comment.
I didn't find anything else major. So I think overall this PR is good. Although I didn't fully test the different scenarios (as described in the PR), the few ones I did were functioning as expected.
Yeah, I think the biggest thing for me is the validation and configuration of 6 or 8 digits.
| ) | ||
|
|
||
| // Wait for OTP input fields to appear and fill the 8-digit code | ||
| const otpCode = '12345678' // Replace with actual OTP code |
There was a problem hiding this comment.
Cool, thank you for updating the E2E tests too.
| interpretPlusSignAsSpace: false | ||
| }, | ||
| login: { | ||
| tokenLength: process.env.OTP_TOKEN_LENGTH || 8, |
There was a problem hiding this comment.
I like the comment that was added to the configuration files found in the create-app package. Let's copy that over to here as well.
|
Perhaps this was an issue that has already been present but I'm seeing that the product I add to the cart is not merging with the ones already in my account. Video sent via Slack |
…edundant checks in OtpAuth component and add unit tests for validation logic.
vmarta
left a comment
There was a problem hiding this comment.
Thanks for addressing the OTP token length.
…-in-login-flows-2 Signed-off-by: Jinsu Ha <91205717+hajinsuha1@users.noreply.github.com>
…s to include validateOtpTokenLength
…-in-login-flows-2 Signed-off-by: Jinsu Ha <91205717+hajinsuha1@users.noreply.github.com>
- introduce a new `login.tokenLength` configuration in default.js that determines the number of input fields to show in the `OtpAuthModal` - update `useAuthModal` and login page to open the `OtpAuthModal` after user clicks "Continue Securely" - update `OtpAuthModal` to include a prop for hiding the `Checkout as Guest` button - update `PasswordlessLogin` component to not hide elements after form has been successfully submitted
Description
Allow shopper to manually input the OTP during the passwordless login flow by displaying an OTP Auth modal after clicking "Continue Securely".
Screenshare.-.2025-12-31.2_31_41.PM.mp4
Types of Changes
Changes
login.tokenLengthconfiguration in default.js that determines the number of input fields to show in theOtpAuthModaluseAuthModaland login page to open theOtpAuthModalafter user clicks "Continue Securely"OtpAuthModalto include a prop for hiding theCheckout as GuestbuttonPasswordlessLogincomponent to not hide elements after form has been successfully submittedHow to Test-Drive This PR
Auth Modal
Login Page
Magic Link
Token Length is configurable via Environment Variable
OTP_TOKEN_LENGTHenv variable and start the appOTP_TOKEN_LENGTHenv variable to an invalid valueOld checkout page displays "Check Your Email" modal when
oneClickCheckoutis disabledProceed to CheckoutSecure LinkOne Click Checkout works when
oneClickCheckoutis enabledOtpAuthModalis opened with 6-digit input and an email is sentE2E Tests
pwa-kit-create-app
default.js,app.login.passwordless.modeandapp.login.resetPassword.modeis set toemailandcallbackURIis commented outdefault.jsapp.login.passwordless.enabledtotruecommerceAPIto use a private clientoverrides/app/ssr.jsuseSLASPrivateClienttotrueapplySLASPrivateClientToEndpointspropertyoverrides/app/components/_app-config/index.jsxaddenablePWAKitPrivateClient={true}to the fields ofCommerceApiProviderChecklists
General
Accessibility Compliance
You must check off all items in one of the follow two lists:
or...
Localization