hotfix: token return add to return URL
This commit is contained in:
@@ -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<AuthMode>('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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user