File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed
packages/template-retail-react-app/app/pages/login Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -148,16 +148,21 @@ const Login = ({initialView = LOGIN_VIEW}) => {
148148 // executing a passwordless login attempt using the token. The process waits for the
149149 // customer baskets to be loaded to guarantee proper basket merging.
150150 useEffect ( ( ) => {
151- if ( path === PASSWORDLESS_LOGIN_LANDING_PATH && isSuccessCustomerBaskets ) {
151+ if ( path === PASSWORDLESS_LOGIN_LANDING_PATH ) {
152152 const token = queryParams . get ( 'token' )
153- try {
154- loginPasswordless . mutate ( { pwdlessLoginToken : token } )
155- } catch ( e ) {
156- const message = / U n a u t h o r i z e d / i. test ( e . message )
157- ? formatMessage ( INVALID_TOKEN_ERROR_MESSAGE )
158- : formatMessage ( API_ERROR_MESSAGE )
159- form . setError ( 'global' , { type : 'manual' , message} )
153+
154+ const passwordlessLogin = async ( ) => {
155+ try {
156+ const res = await loginPasswordless . mutateAsync ( { pwdlessLoginToken : token } )
157+ } catch ( e ) {
158+ const errorData = await e . response ?. json ( )
159+ const message = / i n v a l i d t o k e n / i. test ( errorData . message )
160+ ? formatMessage ( INVALID_TOKEN_ERROR_MESSAGE )
161+ : formatMessage ( API_ERROR_MESSAGE )
162+ form . setError ( 'global' , { type : 'manual' , message} )
163+ }
160164 }
165+ passwordlessLogin ( )
161166 }
162167 } , [ path , isSuccessCustomerBaskets ] )
163168
You can’t perform that action at this time.
0 commit comments