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';
|
import Instance from '../../../components/Connection';
|
||||||
|
|
||||||
|
const visitReporterRoleKey = "VIRPT";
|
||||||
|
|
||||||
class Login extends React.Component {
|
class Login extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
@@ -75,11 +77,23 @@ class Login extends React.Component {
|
|||||||
let auth = res.data;
|
let auth = res.data;
|
||||||
state.setCookie('token', auth.token, auth.valid_time);
|
state.setCookie('token', auth.token, auth.valid_time);
|
||||||
localStorage.setItem('loggedUser', JSON.stringify(auth.user));
|
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);
|
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) {
|
}).catch(function (err) {
|
||||||
|
console.log("ERRR");
|
||||||
|
console.log(err);
|
||||||
state.setState(Object.assign(state.state, {
|
state.setState(Object.assign(state.state, {
|
||||||
message: (err.response.data.message),
|
message: (err.response.data.message),
|
||||||
open: true,
|
open: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user