reg modify

This commit is contained in:
kuwsh1n 2024-04-14 14:17:15 +03:00
parent 247c0b831f
commit 0b48eb739e
4 changed files with 12 additions and 35 deletions

View File

@ -38,6 +38,7 @@ const App = () => {
useEffect(() => { useEffect(() => {
async function verifyUser() { async function verifyUser() {
const response = await verifyUserApi(cookies.token); const response = await verifyUserApi(cookies.token);
console.log("app", user)
if (response) { if (response) {
if (response.status === 200) { if (response.status === 200) {

View File

@ -4,24 +4,9 @@ import classes from "../assets/styles/components/navbar.module.scss";
import { verifyUserApi } from "../hooks/api/enterAccountApi"; import { verifyUserApi } from "../hooks/api/enterAccountApi";
const NavBar = ({navigate, auth, setAuth}) => { const NavBar = ({navigate, auth, setAuth}) => {
// const [cookies, _, __] = useCookies(["user"]); useEffect(() => {
console.log("nav", auth)
// useEffect(() => { })
// async function verifyUser() {
// const response = await verifyUserApi(cookies.token);
// if (response) {
// if (response.status === 200) {
// setAuth(response.data);
// }
// else {
// console.log(response)
// }
// }
// }
// verifyUser()
// }, []);
return ( return (
<div className={classes.main}> <div className={classes.main}>

View File

@ -17,7 +17,7 @@ const totalRegisterValidate = (data) => {
// constructorAnswerValidate(data.email.length, "Обязательное поле."), // constructorAnswerValidate(data.email.length, "Обязательное поле."),
// constructorAnswerValidate(data.phone.length, "Обязательное поле."), // constructorAnswerValidate(data.phone.length, "Обязательное поле."),
constructorAnswerValidate(data.password === data.repiedPassword, "Введенные пароли не совпадают."), constructorAnswerValidate(data.password === data.repiedPassword, "Введенные пароли не совпадают."),
constructorAnswerValidate(data.password >= 8, "Пароль должен иметь более 8 символов.") // constructorAnswerValidate(data.password >= 8, "Пароль должен иметь более 8 символов.")
] ]
for (let value of listValidation) { for (let value of listValidation) {

View File

@ -45,18 +45,11 @@ const EnterAccount = () => {
}); });
if (response.status === 200) { if (response.status === 200) {
setUser({ const responseMe = await verifyUserApi(response.data.token)
email: email, setUser(responseMe.data);
phone: phone,
login: login,
surname: surname,
patronymic: patronymic,
password: password,
});
setCookie("token", response.data.token); setCookie("token", response.data.token);
cleanState(); cleanState();
window.location.reload(); navigate("/");
// navigate("/");
} }
else { else {
console.log("Error") console.log("Error")
@ -68,13 +61,11 @@ const EnterAccount = () => {
if (response.status === 200) { if (response.status === 200) {
setCookie("token", response.data.token); setCookie("token", response.data.token);
const responseMe = await verifyUserApi(response.data.token)
setUser(responseMe.data)
cleanState(); cleanState();
// setUser({ navigate("/")
// login: login
// })
window.location.reload();
// navigate("/")
// window.location.reload()
} }
else { else {
console.log(response) console.log(response)