auth work
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user