auth work

This commit is contained in:
Romulus21
2024-07-17 07:09:04 +02:00
parent 6be48846b0
commit a34eadb51f
13 changed files with 1125 additions and 1042 deletions

View File

@@ -3,12 +3,10 @@ import Field from "../../components/Field"
import axios from "axios"
import {useNavigate} from "react-router-dom"
import Card from "../../components/Card"
import useAuthUser from "../../hooks/AuthUser"
const Register = () => {
const navigate = useNavigate()
const {setAuthUser} = useAuthUser()
const [name, setName] = useState('')
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
@@ -17,9 +15,8 @@ const Register = () => {
event.preventDefault()
try {
await axios.get('/sanctum/csrf-cookie')
const res = await axios.post('/api/register', {name, email, password})
setAuthUser(res.data)
navigate('/')
await axios.post('/api/register', {name, email, password})
navigate('/connexion')
} catch (e) {
console.error(e)
}