redirect url
This commit is contained in:
@@ -14,7 +14,7 @@ import { ErrorType } from '../../../helpers/types'
|
||||
import { toast } from 'react-toastify'
|
||||
import { setRefreshToken } from '../../../config/func'
|
||||
import { setToken } from '../../../config/func'
|
||||
|
||||
import { getRedirectUrl } from '../../../config/func'
|
||||
const LoginStep2: FC = () => {
|
||||
|
||||
const { t } = useTranslation('global')
|
||||
@@ -41,6 +41,12 @@ const LoginStep2: FC = () => {
|
||||
onSuccess(data) {
|
||||
setToken(data?.data?.accessToken?.token)
|
||||
setRefreshToken(data?.data?.refreshToken?.token)
|
||||
// Check if there's a redirect parameter in the URL
|
||||
const redirectUrl = getRedirectUrl();
|
||||
if (redirectUrl) {
|
||||
window.location.href = redirectUrl;
|
||||
return; // Prevent the default navigation
|
||||
}
|
||||
window.location.href = Pages.dashboard
|
||||
},
|
||||
onError(error: ErrorType) {
|
||||
@@ -63,7 +69,6 @@ const LoginStep2: FC = () => {
|
||||
} as CredentialRequestOptions) // اطمینان از تطابق تایپها
|
||||
.then((otpCredential) => {
|
||||
if (otpCredential && "code" in otpCredential) {
|
||||
alert("OTP Received: " + otpCredential.code);
|
||||
formik.setFieldValue("code", (otpCredential).code);
|
||||
}
|
||||
})
|
||||
|
||||
@@ -15,6 +15,7 @@ import { toast } from 'react-toastify'
|
||||
import { ErrorType } from '../../../helpers/types'
|
||||
import { setRefreshToken } from '../../../config/func'
|
||||
import { setToken } from '../../../config/func'
|
||||
import { getRedirectUrl } from '../../../config/func'
|
||||
|
||||
const LoginStep3: FC = () => {
|
||||
|
||||
@@ -37,6 +38,11 @@ const LoginStep3: FC = () => {
|
||||
onSuccess(data) {
|
||||
setToken(data?.data?.accessToken?.token)
|
||||
setRefreshToken(data?.data?.refreshToken?.token)
|
||||
const redirectUrl = getRedirectUrl();
|
||||
if (redirectUrl) {
|
||||
window.location.href = redirectUrl;
|
||||
return; // Prevent the default navigation
|
||||
}
|
||||
window.location.href = Pages.dashboard
|
||||
},
|
||||
onError(error: ErrorType) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import { toast } from 'react-toastify'
|
||||
import { Pages } from '../../../config/Pages'
|
||||
import { setToken } from '../../../config/func'
|
||||
import { setRefreshToken } from '../../../config/func'
|
||||
|
||||
import { getRedirectUrl } from '../../../config/func'
|
||||
const RegisterStep2: FC = () => {
|
||||
|
||||
const { t } = useTranslation('global')
|
||||
@@ -51,6 +51,11 @@ const RegisterStep2: FC = () => {
|
||||
onSuccess(data) {
|
||||
setToken(data?.data?.accessToken?.token)
|
||||
setRefreshToken(data?.data?.refreshToken?.token)
|
||||
const redirectUrl = getRedirectUrl();
|
||||
if (redirectUrl) {
|
||||
window.location.href = redirectUrl;
|
||||
return; // Prevent the default navigation
|
||||
}
|
||||
window.location.href = Pages.dashboard
|
||||
},
|
||||
onError(error: ErrorType) {
|
||||
|
||||
Reference in New Issue
Block a user