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 type { CountryCode } from '@/types/commonTypes';
|
||||||
import { VerifyPhoneNumber } from './VerifyPhoneNumber';
|
import { VerifyPhoneNumber } from './VerifyPhoneNumber';
|
||||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||||
|
import { REFRESH_TOKEN_KEY } from '@/providers/AuthProvider';
|
||||||
|
|
||||||
export const AuthenticationSteps = (): JSX.Element => {
|
export const AuthenticationSteps = (): JSX.Element => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const authReturnUrl: string | null = searchParams.get('returnUrl');
|
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 =
|
const authReturnUrlOrDefault: string =
|
||||||
authReturnUrl ?? import.meta.env.VITE_DEFUALT_AUTH_RETURN_URL;
|
authReturnUrl ?? import.meta.env.VITE_DEFUALT_AUTH_RETURN_URL;
|
||||||
const [authMode, setAuthMode] = useState<AuthMode>('register');
|
const [authMode, setAuthMode] = useState<AuthMode>('register');
|
||||||
@@ -57,7 +61,7 @@ export const AuthenticationSteps = (): JSX.Element => {
|
|||||||
|
|
||||||
if (!loginResult.completedUserInformation) {
|
if (!loginResult.completedUserInformation) {
|
||||||
if (authReturnUrl) {
|
if (authReturnUrl) {
|
||||||
navigate(`/signup?returnUrl=${authReturnUrl}`);
|
navigate(`/signup?returnUrl=${authReturnUrlWithRefreshToken}`);
|
||||||
} else {
|
} else {
|
||||||
navigate(`/signup`);
|
navigate(`/signup`);
|
||||||
}
|
}
|
||||||
@@ -69,7 +73,7 @@ export const AuthenticationSteps = (): JSX.Element => {
|
|||||||
|
|
||||||
const handlePhoneNumberVerified = () => {
|
const handlePhoneNumberVerified = () => {
|
||||||
if (authReturnUrl) {
|
if (authReturnUrl) {
|
||||||
navigate(`/signup?returnUrl=${authReturnUrl}`);
|
navigate(`/signup?returnUrl=${authReturnUrlWithRefreshToken}`);
|
||||||
} else {
|
} else {
|
||||||
navigate(`/signup`);
|
navigate(`/signup`);
|
||||||
}
|
}
|
||||||
@@ -80,9 +84,10 @@ export const AuthenticationSteps = (): JSX.Element => {
|
|||||||
navigate(import.meta.env.VITE_DEFUALT_AUTH_RETURN_URL);
|
navigate(import.meta.env.VITE_DEFUALT_AUTH_RETURN_URL);
|
||||||
} else {
|
} else {
|
||||||
if (authMode === 'register') {
|
if (authMode === 'register') {
|
||||||
navigate(`/account-created?returnUrl=${authReturnUrl}`);
|
navigate(`/account-created?returnUrl=${authReturnUrlWithRefreshToken}`);
|
||||||
} else {
|
} else {
|
||||||
location.href = authReturnUrl;
|
alert(authReturnUrlWithRefreshToken);
|
||||||
|
location.href = authReturnUrlWithRefreshToken;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user