Compare commits
2 Commits
master
...
login-redi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5de4eeaef4 | ||
|
|
3ca1dc2682 |
@@ -8,6 +8,8 @@ import Dialog from 'material-ui/Dialog';
|
||||
|
||||
import Instance from '../../../components/Connection';
|
||||
|
||||
const visitReporterRoleKey = "VIRPT";
|
||||
|
||||
class Login extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@@ -75,11 +77,23 @@ class Login extends React.Component {
|
||||
let auth = res.data;
|
||||
state.setCookie('token', auth.token, auth.valid_time);
|
||||
localStorage.setItem('loggedUser', JSON.stringify(auth.user));
|
||||
console.log(auth.user);
|
||||
|
||||
let isAuthUserVisitReporter = false;
|
||||
if (auth.user.profiles.length > 0){
|
||||
isAuthUserVisitReporter = (auth.user.profiles[0].key===visitReporterRoleKey);
|
||||
}
|
||||
|
||||
Instance.setToken(auth.token);
|
||||
|
||||
location.href = '/#/';
|
||||
if (isAuthUserVisitReporter) {
|
||||
location.href = '/#/app/form/visit/' + auth.user.useruuid;
|
||||
}else{
|
||||
location.href = '/#/app/table/rides';
|
||||
}
|
||||
}).catch(function (err) {
|
||||
console.log("ERRR");
|
||||
console.log(err);
|
||||
state.setState(Object.assign(state.state, {
|
||||
message: (err.response.data.message),
|
||||
open: true,
|
||||
|
||||
Reference in New Issue
Block a user