fix: Add csrf token to login page
This commit is contained in:
parent
fda3de4d32
commit
d0716a0ad1
@ -2,11 +2,12 @@ import { API, URL, getCookie } from '../../API';
|
|||||||
import * as S from '../../styles/Form.styles';
|
import * as S from '../../styles/Form.styles';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import CSRFToken from '../CSRFToken/CSRFToken';
|
import CSRFToken from '../CSRFToken/CSRFToken';
|
||||||
import { Navigate, useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import useIsLogged from '../../hooks/network/isLogged';
|
import useIsLogged from '../../hooks/network/isLogged';
|
||||||
|
|
||||||
const LoginForm = () => {
|
const LoginForm = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const csrfToken = getCookie('csrftoken');
|
||||||
const setIsLogged = useIsLogged((state) => state.setIsLogged);
|
const setIsLogged = useIsLogged((state) => state.setIsLogged);
|
||||||
const [username, setUsername] = useState('');
|
const [username, setUsername] = useState('');
|
||||||
const [password, setPassword] = useState('');
|
const [password, setPassword] = useState('');
|
||||||
@ -15,6 +16,7 @@ const LoginForm = () => {
|
|||||||
API.post(URL.login, {
|
API.post(URL.login, {
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
|
csrfmiddlewaretoken: csrfToken,
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
|
Loading…
Reference in New Issue
Block a user