fix: Add csrf token to login page

This commit is contained in:
jhynsoo 2023-11-14 02:35:15 +09:00
parent fda3de4d32
commit d0716a0ad1

View File

@ -2,11 +2,12 @@ import { API, URL, getCookie } from '../../API';
import * as S from '../../styles/Form.styles';
import { useState } from 'react';
import CSRFToken from '../CSRFToken/CSRFToken';
import { Navigate, useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
import useIsLogged from '../../hooks/network/isLogged';
const LoginForm = () => {
const navigate = useNavigate();
const csrfToken = getCookie('csrftoken');
const setIsLogged = useIsLogged((state) => state.setIsLogged);
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
@ -15,6 +16,7 @@ const LoginForm = () => {
API.post(URL.login, {
username,
password,
csrfmiddlewaretoken: csrfToken,
})
.then((res) => {
if (res.status === 200) {