-
Notifications
You must be signed in to change notification settings - Fork 212
@W-17550783 - [Passwordless login] Redirect customer to page prior to login #2221
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 18 commits
24c7a7b
fb7c92f
02fc981
272405a
10a22c3
c2a6941
4b64139
1d20200
a45ed60
54436ac
84ab168
7051eec
4e9945f
5b9deca
b40e815
3dc0d43
b831c17
39876bd
b7b7d62
e23bdce
73f6482
cd1517c
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('') | ||
|
||
| } | ||
| }, [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
passwordlessConfigCallbackis a relative path it creates the URL correclty?