redirect url

This commit is contained in:
hamid zarghami
2025-04-21 11:50:49 +03:30
parent 6badc5fb31
commit 1e134c1e19
7 changed files with 48 additions and 23 deletions
+7 -2
View File
@@ -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);
}
})
+6
View File
@@ -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) {
+6 -1
View File
@@ -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) {