Skip to content
Snippets Groups Projects

Polished auth flow including ReservedRoute and role selection.

Merged Defendi Alberto requested to merge feature/privateroute/role into dev
1 file
+ 3
2
Compare changes
  • Side-by-side
  • Inline
@@ -4,7 +4,7 @@ import { SubmitHandler, useForm } from 'react-hook-form';
import { Button } from '@material-ui/core';
import { InputField } from 'components/AuthUser/InputField/InputField';
import { useHistory } from 'react-router-dom';
import { AuthRoutes } from 'api/routes';
import { AuthRoutes, NonAuthRoutes } from 'api/routes';
import { AuthContext } from 'components/AuthUser/AuthContext';
import { fetchCookie } from 'api/fetchCookie';
import { useStyles } from './useStyles';
@@ -52,7 +52,6 @@ export const SignInForm: FC = () => {
},
)
.then((response) => {
console.log(response);
if (response.data.status === 'fail') {
setError('username', {
type: 'server',
@@ -62,6 +61,8 @@ export const SignInForm: FC = () => {
type: 'server',
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') {
setRole(response.data.role);
setIsAuth(true);
Loading