-
Notifications
You must be signed in to change notification settings - Fork 144
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
@W-17550783 - [Passwordless login] Redirect customer to page prior to login #2221
base: feature-passwordless-social-login
Are you sure you want to change the base?
Changes from 18 commits
24c7a7b
fb7c92f
02fc981
272405a
10a22c3
c2a6941
4b64139
1d20200
a45ed60
54436ac
84ab168
7051eec
4e9945f
5b9deca
b40e815
3dc0d43
b831c17
39876bd
b7b7d62
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 |
---|---|---|
|
@@ -75,6 +75,7 @@ const Login = ({initialView = LOGIN_VIEW}) => { | |
const [currentView, setCurrentView] = useState(initialView) | ||
const [passwordlessLoginEmail, setPasswordlessLoginEmail] = useState('') | ||
const [loginType, setLoginType] = useState(LOGIN_TYPES.PASSWORD) | ||
const [redirectPath, setRedirectPath] = useState('') | ||
|
||
const handleMergeBasket = () => { | ||
const hasBasketItem = baskets?.baskets?.[0]?.productItems?.length > 0 | ||
|
@@ -149,7 +150,10 @@ const Login = ({initialView = LOGIN_VIEW}) => { | |
// customer baskets to be loaded to guarantee proper basket merging. | ||
useEffect(() => { | ||
if (path === PASSWORDLESS_LOGIN_LANDING_PATH && isSuccessCustomerBaskets) { | ||
const token = queryParams.get('token') | ||
const token = decodeURIComponent(queryParams.get('token')) | ||
if (queryParams.get('redirect_url')) { | ||
setRedirectPath(decodeURIComponent(queryParams.get('redirect_url'))) | ||
} | ||
|
||
const passwordlessLogin = async () => { | ||
try { | ||
|
@@ -170,11 +174,9 @@ const Login = ({initialView = LOGIN_VIEW}) => { | |
useEffect(() => { | ||
if (isRegistered) { | ||
handleMergeBasket() | ||
if (location?.state?.directedFrom) { | ||
navigate(location.state.directedFrom) | ||
} else { | ||
navigate('/account') | ||
} | ||
const redirectTo = redirectPath ? redirectPath : '/account' | ||
navigate(redirectTo) | ||
setRedirectPath('') | ||
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. I feel like this line here can potentially cause react warning about unsettable state. We are navigating away before the state can be set. |
||
} | ||
}, [isRegistered]) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: is there a way to add a unit test that verfies when
passwordlessConfigCallback
is a relative path it creates the URL correclty?