From b8de694a2af4040279e0580a7e8c0da826f10e46 Mon Sep 17 00:00:00 2001 From: mehrzadghdev Date: Fri, 22 Aug 2025 00:48:35 +0330 Subject: [PATCH] hotfix: token return add to return URL --- .../AuthenticationSteps/AuthenticationSteps.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/features/authentication/components/AuthenticationSteps/AuthenticationSteps.tsx b/src/features/authentication/components/AuthenticationSteps/AuthenticationSteps.tsx index 598eaa6..a2511e0 100644 --- a/src/features/authentication/components/AuthenticationSteps/AuthenticationSteps.tsx +++ b/src/features/authentication/components/AuthenticationSteps/AuthenticationSteps.tsx @@ -9,11 +9,15 @@ import { UserStatus, type LoginResult } from '../../types/userTypes'; import type { CountryCode } from '@/types/commonTypes'; import { VerifyPhoneNumber } from './VerifyPhoneNumber'; import { useNavigate, useSearchParams } from 'react-router-dom'; +import { REFRESH_TOKEN_KEY } from '@/providers/AuthProvider'; export const AuthenticationSteps = (): JSX.Element => { const navigate = useNavigate(); const [searchParams] = useSearchParams(); const authReturnUrl: string | null = searchParams.get('returnUrl'); + const authReturnUrlWithRefreshToken = + authReturnUrl + `?token=${sessionStorage.getItem(REFRESH_TOKEN_KEY)}`; + authReturnUrl + `?token=${sessionStorage.getItem(REFRESH_TOKEN_KEY)}`; const authReturnUrlOrDefault: string = authReturnUrl ?? import.meta.env.VITE_DEFUALT_AUTH_RETURN_URL; const [authMode, setAuthMode] = useState('register'); @@ -57,7 +61,7 @@ export const AuthenticationSteps = (): JSX.Element => { if (!loginResult.completedUserInformation) { if (authReturnUrl) { - navigate(`/signup?returnUrl=${authReturnUrl}`); + navigate(`/signup?returnUrl=${authReturnUrlWithRefreshToken}`); } else { navigate(`/signup`); } @@ -69,7 +73,7 @@ export const AuthenticationSteps = (): JSX.Element => { const handlePhoneNumberVerified = () => { if (authReturnUrl) { - navigate(`/signup?returnUrl=${authReturnUrl}`); + navigate(`/signup?returnUrl=${authReturnUrlWithRefreshToken}`); } else { navigate(`/signup`); } @@ -80,9 +84,10 @@ export const AuthenticationSteps = (): JSX.Element => { navigate(import.meta.env.VITE_DEFUALT_AUTH_RETURN_URL); } else { if (authMode === 'register') { - navigate(`/account-created?returnUrl=${authReturnUrl}`); + navigate(`/account-created?returnUrl=${authReturnUrlWithRefreshToken}`); } else { - location.href = authReturnUrl; + alert(authReturnUrlWithRefreshToken); + location.href = authReturnUrlWithRefreshToken; } } };