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

Set isAuth after role is chosen.

parent d1e33f2c
No related branches found
No related tags found
3 merge requests!56Refined auth flow and new website pages.,!53Feature/authorization/curry,!52Change folder structure and fix auth flow.
import React, { FC, useEffect, useState } from 'react';
import React, { FC, useContext, useEffect, useState } from 'react';
import Button from '@material-ui/core/Button';
import { getRoles } from 'api/getRoles';
import { setRole } from 'api/setRole';
import { useHistory } from 'react-router-dom';
import { AuthRoutes } from 'api/routes';
import { AuthContext } from 'components/Auth/AuthContext';
/**
* Page that let's users decide role between available roles.
......@@ -13,10 +14,12 @@ import { AuthRoutes } from 'api/routes';
export const ChoseRole: FC = () => {
const history = useHistory();
const [userRoles, setUserRoles] = useState<string[]>(['']);
const { setIsAuth } = useContext(AuthContext);
const choseAndForward = (role: string): void => {
// Set role in the server.
setRole(role);
setIsAuth(true);
// Push to homepage.
history.push(`${AuthRoutes.dashboard}${AuthRoutes.home}`);
};
......
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