auth work
This commit is contained in:
@@ -34,19 +34,24 @@ const Login = () => {
|
||||
</h1>
|
||||
{errorLabel()}
|
||||
|
||||
<Field type="email"
|
||||
name="email"
|
||||
placeholder="Email"
|
||||
value={email}
|
||||
onChange={event => setEmail(event.target.value)}
|
||||
autoFocus>Email</Field>
|
||||
<Field type="password"
|
||||
name="password"
|
||||
placeholder="******"
|
||||
value={password}
|
||||
onChange={event => setPassword(event.target.value)}>Mot de passe</Field>
|
||||
<button type="submit" className="btn-primary mt-5 block w-full text-lg">Valider</button>
|
||||
<Link to="/mot-de-passe-oubliee" className="mt-2 inline-block">Mot de passe oublié ?</Link>
|
||||
<Field type="email"
|
||||
name="email"
|
||||
placeholder="Email"
|
||||
value={email}
|
||||
onChange={event => setEmail(event.target.value)}
|
||||
autoFocus>Email</Field>
|
||||
<Field type="password"
|
||||
name="password"
|
||||
placeholder="******"
|
||||
value={password}
|
||||
onChange={event => setPassword(event.target.value)}>Mot de passe</Field>
|
||||
|
||||
<Field type="hidden"
|
||||
value={1}
|
||||
name="form_info" onChange={() => setPassword('')}/>
|
||||
|
||||
<button type="submit" className="btn-primary mt-5 block w-full text-lg">Valider</button>
|
||||
<Link to="/mot-de-passe-oubliee" className="mt-2 inline-block">Mot de passe oublié ?</Link>
|
||||
</form>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import Register from "./Auth/Register"
|
||||
import ToDoShow from "./ToDos/ToDoShow"
|
||||
import TimeTrackersIndex from "./TimeTrackersIndex"
|
||||
import {env} from "../utilities/env"
|
||||
import Reset from "./Auth/Reset"
|
||||
import ForgotPassword from "./Auth/ForgotPassword"
|
||||
|
||||
const Router = () => {
|
||||
|
||||
@@ -26,6 +28,8 @@ const Router = () => {
|
||||
<Route path="/connexion" element={<Login />} />
|
||||
{env.VITE_REGISTER_DISABLED === 'false' && <Route path="/sinscrire" element={<Register />} />}
|
||||
<Route path="/todos/:id" element={<ToDoShow />} />
|
||||
<Route path="/mot-de-passe-oubliee" element={<ForgotPassword />} />
|
||||
<Route path="/reset/:token" element={<Reset />} />
|
||||
<Route path="/times" element={<TimeTrackersIndex />} />
|
||||
</Routes>
|
||||
</Suspense>
|
||||
|
||||
Reference in New Issue
Block a user