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

Redirect to page if user has multiple roles.

parent 4b426dd6
No related branches found
No related tags found
2 merge requests!56Refined auth flow and new website pages.,!45Polished auth flow including ReservedRoute and role selection.
...@@ -4,7 +4,7 @@ import { SubmitHandler, useForm } from 'react-hook-form'; ...@@ -4,7 +4,7 @@ import { SubmitHandler, useForm } from 'react-hook-form';
import { Button } from '@material-ui/core'; import { Button } from '@material-ui/core';
import { InputField } from 'components/AuthUser/InputField/InputField'; import { InputField } from 'components/AuthUser/InputField/InputField';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import { AuthRoutes } from 'api/routes'; import { AuthRoutes, NonAuthRoutes } from 'api/routes';
import { AuthContext } from 'components/AuthUser/AuthContext'; import { AuthContext } from 'components/AuthUser/AuthContext';
import { fetchCookie } from 'api/fetchCookie'; import { fetchCookie } from 'api/fetchCookie';
import { useStyles } from './useStyles'; import { useStyles } from './useStyles';
...@@ -52,7 +52,6 @@ export const SignInForm: FC = () => { ...@@ -52,7 +52,6 @@ export const SignInForm: FC = () => {
}, },
) )
.then((response) => { .then((response) => {
console.log(response);
if (response.data.status === 'fail') { if (response.data.status === 'fail') {
setError('username', { setError('username', {
type: 'server', type: 'server',
...@@ -62,6 +61,8 @@ export const SignInForm: FC = () => { ...@@ -62,6 +61,8 @@ export const SignInForm: FC = () => {
type: 'server', type: 'server',
message: 'Something went wrong with password', message: 'Something went wrong with password',
}); });
} else if (response.data.status === 'role-choice-needed') {
history.replace(`${NonAuthRoutes.auth}${AuthRoutes.choseRole}`);
} else if (response.data.status === 'success') { } else if (response.data.status === 'success') {
setRole(response.data.role); setRole(response.data.role);
setIsAuth(true); setIsAuth(true);
......
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