fix changepwd
This commit is contained in:
parent
b0610b55db
commit
a6a89b0bd3
@ -54,6 +54,8 @@ export default function RecoverPassword() {
|
|||||||
initialValues,
|
initialValues,
|
||||||
validationSchema,
|
validationSchema,
|
||||||
onSubmit: async (values, formikHelpers) => {
|
onSubmit: async (values, formikHelpers) => {
|
||||||
|
console.log("tokenUser", tokenUser);
|
||||||
|
|
||||||
if (tokenUser) {
|
if (tokenUser) {
|
||||||
setAuthToken(tokenUser || "");
|
setAuthToken(tokenUser || "");
|
||||||
const [_, recoverError] = await recoverUser(values.password);
|
const [_, recoverError] = await recoverUser(values.password);
|
||||||
@ -74,9 +76,12 @@ export default function RecoverPassword() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
console.log("RecoverPassword useEffect - window.location.search:", window.location.search);
|
||||||
|
console.log("RecoverPassword useEffect - window.location.href:", window.location.href);
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
const authToken = params.get("auth");
|
const authToken = params.get("auth");
|
||||||
setTokenUser(authToken);
|
console.log("RecoverPassword useEffect - authToken:", authToken);
|
||||||
|
setTokenUser(authToken || "");
|
||||||
|
|
||||||
history.pushState(null, document.title, "/changepwd");
|
history.pushState(null, document.title, "/changepwd");
|
||||||
return () => {
|
return () => {
|
||||||
|
@ -2,7 +2,7 @@ import { cartApi } from "@api/cart";
|
|||||||
import { useUserStore } from "@/stores/user";
|
import { useUserStore } from "@/stores/user";
|
||||||
import { enqueueSnackbar } from "notistack";
|
import { enqueueSnackbar } from "notistack";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useNavigate, useSearchParams } from "react-router-dom";
|
import { useNavigate, useSearchParams, useLocation } from "react-router-dom";
|
||||||
import { calcTimeOfReadyPayCart, cancelPayCartProcess, startPayCartProcess, useNotEnoughMoneyAmount } from "@/stores/notEnoughMoneyAmount";
|
import { calcTimeOfReadyPayCart, cancelPayCartProcess, startPayCartProcess, useNotEnoughMoneyAmount } from "@/stores/notEnoughMoneyAmount";
|
||||||
import { startCC } from "@/stores/cc";
|
import { startCC } from "@/stores/cc";
|
||||||
import { setEditQuizId, setCurrentStep } from "@root/quizes/actions";
|
import { setEditQuizId, setCurrentStep } from "@root/quizes/actions";
|
||||||
@ -17,6 +17,7 @@ import { setEditQuizId, setCurrentStep } from "@root/quizes/actions";
|
|||||||
export const useAfterPay = () => {
|
export const useAfterPay = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [searchParams, setSearchParams] = useSearchParams();
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
const userId = useUserStore(store => store.userId)
|
const userId = useUserStore(store => store.userId)
|
||||||
const userAccount = useUserStore(state => state.userAccount);
|
const userAccount = useUserStore(state => state.userAccount);
|
||||||
@ -28,8 +29,28 @@ export const useAfterPay = () => {
|
|||||||
let URLadditionalinformation = searchParams.get("additionalinformation");//его токен
|
let URLadditionalinformation = searchParams.get("additionalinformation");//его токен
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// Проверяем, открыта ли модалка восстановления пароля
|
||||||
|
const isRecoverPasswordModal = location.state?.backgroundLocation?.pathname === "/changepwd";
|
||||||
|
|
||||||
setSearchParams({}, { replace: true });
|
// Проверяем, есть ли токен восстановления пароля в URL
|
||||||
|
const hasAuthToken = searchParams.get("auth") || window.location.search.includes("auth=");
|
||||||
|
|
||||||
|
console.log("useAfterPay debug:", {
|
||||||
|
pathname: location.pathname,
|
||||||
|
backgroundLocation: location.state?.backgroundLocation,
|
||||||
|
isRecoverPasswordModal,
|
||||||
|
searchParams: window.location.search,
|
||||||
|
authToken: searchParams.get("auth"),
|
||||||
|
hasAuthToken
|
||||||
|
});
|
||||||
|
|
||||||
|
// НЕ очищаем параметры на странице восстановления пароля, когда открыты модалки или есть токен auth
|
||||||
|
if (location.pathname !== "/changepwd" && !location.state?.backgroundLocation && !isRecoverPasswordModal && !hasAuthToken) {
|
||||||
|
console.log("Очищаем параметры URL");
|
||||||
|
setSearchParams({}, { replace: true });
|
||||||
|
} else {
|
||||||
|
console.log("НЕ очищаем параметры URL");
|
||||||
|
}
|
||||||
|
|
||||||
if (userId && URLuserId && userId === URLuserId) {
|
if (userId && URLuserId && userId === URLuserId) {
|
||||||
|
|
||||||
@ -78,7 +99,7 @@ export const useAfterPay = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}, []);
|
}, [location.pathname, location.state?.backgroundLocation]);
|
||||||
|
|
||||||
//Обработка необходимости купить после пополнения
|
//Обработка необходимости купить после пополнения
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user