Skip to content
Snippets Groups Projects
Verified Commit 20c7d864 authored by Defendi Alberto's avatar Defendi Alberto
Browse files

Remove cookie call

parent ae517281
No related branches found
No related tags found
2 merge requests!56Refined auth flow and new website pages.,!41Sign up form setup
Pipeline #12010 failed
import React, { FC, useEffect } from 'react'; import React, { FC } from 'react';
import axios from 'axios';
import Container from '@material-ui/core/Container'; import Container from '@material-ui/core/Container';
import { Route, useRouteMatch } from 'react-router-dom'; import { Route, useRouteMatch } from 'react-router-dom';
import { NonAuthRoutes } from 'components/api/routes'; import { NonAuthRoutes } from 'components/api/routes';
import { SignInForm } from 'components/AuthUser/SignInForm/SignInForm'; import { SignInForm } from 'components/AuthUser/SignInForm/SignInForm';
import { SignUpForm } from 'components/AuthUser/SignUpForm/SignUpForm'; import { SignUpForm } from 'components/AuthUser/SignUpForm/SignUpForm';
const configDjangoCookieName = (): void => {
axios.defaults.xsrfHeaderName = 'X-CSRFTOKEN';
axios.defaults.xsrfCookieName = 'csrftoken';
axios.defaults.withCredentials = true;
};
export const AuthUser: FC = () => { export const AuthUser: FC = () => {
const { path } = useRouteMatch(); const { path } = useRouteMatch();
configDjangoCookieName();
useEffect(() => {
axios
.get('api/web/csrf')
.then((response) => {
axios.defaults.headers.common['X-CSRFTOKEN'] = response.data.token;
sessionStorage.setItem('X-CSRFTOKEN', response.data.token);
sessionStorage.setItem('ROLE', 'admin');
})
.catch((error) => error);
}, []);
return ( return (
<Container maxWidth="sm"> <Container maxWidth="sm">
<Route path={`${path}${NonAuthRoutes.signIn}`} component={SignInForm} /> <Route path={`${path}${NonAuthRoutes.signIn}`} component={SignInForm} />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment