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(() => {
async function verifyUser() {
const response = await verifyUserApi(cookies.token);
console.log("app", user)
if (response) {
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";
const NavBar = ({navigate, auth, setAuth}) => {
// const [cookies, _, __] = useCookies(["user"]);
// useEffect(() => {
// async function verifyUser() {
// const response = await verifyUserApi(cookies.token);
// if (response) {
// if (response.status === 200) {
// setAuth(response.data);
// }
// else {
// console.log(response)
// }
// }
// }
// verifyUser()
// }, []);
useEffect(() => {
console.log("nav", auth)
})
return (
<div className={classes.main}>

View File

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

View File

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