diff --git a/components/doctor/claim/index.js b/components/doctor/claim/index.js index b66ec22..f1badbe 100644 --- a/components/doctor/claim/index.js +++ b/components/doctor/claim/index.js @@ -1,7 +1,7 @@ "use client"; import { useState } from "react"; -import { useRouter } from "next/navigation"; +import { useRouter, usePathname } from "next/navigation"; import Link from "next/link"; import { Box, Button, Modal, TextField } from "@mui/material"; import { styleDefault } from "@/mui"; @@ -20,6 +20,7 @@ const initialForm = { national_code: "", birth_date: "", first_name: "", last_na */ function ClaimProfileSection({ doctor }) { const router = useRouter(); + const pathname = usePathname(); const [open, setOpen] = useState(false); const [form, setForm] = useState(initialForm); const [fieldErrors, setFieldErrors] = useState({}); @@ -179,7 +180,7 @@ function ClaimProfileSection({ doctor }) { برای احراز مالکیت، ابتدا با شماره موبایل خود وارد شوید. پس از ورود، به همین صفحه بازگردید و دوباره تلاش کنید.

- + diff --git a/components/register/verificationPage/SendReq.js b/components/register/verificationPage/SendReq.js index 8cd7585..94999b0 100644 --- a/components/register/verificationPage/SendReq.js +++ b/components/register/verificationPage/SendReq.js @@ -86,7 +86,12 @@ function SendReq({ if (setStep) { setStep(3); } else { - window.location.href = "/"; + // بازگشت به صفحهٔ مبدأ اگر ?redirect= داده شده (فقط مسیر داخلی امن) + const redirect = new URLSearchParams(window.location.search).get("redirect"); + window.location.href = + redirect && redirect.startsWith("/") && !redirect.startsWith("//") + ? redirect + : "/"; } } else { setIsError(true); diff --git a/helper/index.js b/helper/index.js index d8c1687..f6b6198 100644 --- a/helper/index.js +++ b/helper/index.js @@ -681,8 +681,8 @@ export function timeAgo(timestamp) { } export function isUserLoggedIn() { - const userInfo = Cookies.get("access_token"); - return !!userInfo; + // access_token در memory است نه کوکی؛ userInfo کوکیِ non-httpOnly است که هنگام لاگین ست می‌شود. + return !!Cookies.get("userInfo"); } export function convertTimestampToPersianDateSimple(timestamp) {