Compare commits
2 Commits
hide-profi
...
login-redi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5de4eeaef4 | ||
|
|
3ca1dc2682 |
@@ -4,12 +4,6 @@ import MenuItem from 'material-ui/MenuItem';
|
|||||||
import IconButton from 'material-ui/IconButton/IconButton';
|
import IconButton from 'material-ui/IconButton/IconButton';
|
||||||
import { hashHistory } from 'react-router';
|
import { hashHistory } from 'react-router';
|
||||||
|
|
||||||
import {
|
|
||||||
loggedUser,
|
|
||||||
visitReporter,
|
|
||||||
} from 'utils/authorization';
|
|
||||||
|
|
||||||
|
|
||||||
const ImgIconButtonStyle = {
|
const ImgIconButtonStyle = {
|
||||||
width: '60px',
|
width: '60px',
|
||||||
height: '60px'
|
height: '60px'
|
||||||
@@ -54,7 +48,6 @@ class NavRightList extends React.Component {
|
|||||||
targetOrigin={{ horizontal: 'right', vertical: 'top' }}
|
targetOrigin={{ horizontal: 'right', vertical: 'top' }}
|
||||||
menuStyle={{ minWidth: '150px' }}
|
menuStyle={{ minWidth: '150px' }}
|
||||||
>
|
>
|
||||||
{!loggedUser.anyOf(visitReporter) &&
|
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onTouchTap={(e) => this.handleChange(e, `/app/authorizedusers/${this.state.useruuid}`)}
|
onTouchTap={(e) => this.handleChange(e, `/app/authorizedusers/${this.state.useruuid}`)}
|
||||||
primaryText="Profile"
|
primaryText="Profile"
|
||||||
@@ -62,8 +55,6 @@ class NavRightList extends React.Component {
|
|||||||
innerDivStyle={listItemStyle}
|
innerDivStyle={listItemStyle}
|
||||||
leftIcon={<i className="material-icons">account_circle</i>}
|
leftIcon={<i className="material-icons">account_circle</i>}
|
||||||
/>
|
/>
|
||||||
}
|
|
||||||
{!loggedUser.anyOf(visitReporter) &&
|
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onTouchTap={(e) => this.handleChange(e, `/app/form/steppers/${this.state.useruuid}`)}
|
onTouchTap={(e) => this.handleChange(e, `/app/form/steppers/${this.state.useruuid}`)}
|
||||||
primaryText="Book Ride"
|
primaryText="Book Ride"
|
||||||
@@ -71,16 +62,6 @@ class NavRightList extends React.Component {
|
|||||||
style={{ fontSize: '14px', lineHeight: '48px' }}
|
style={{ fontSize: '14px', lineHeight: '48px' }}
|
||||||
leftIcon={<i className="material-icons">mode_edit</i>}
|
leftIcon={<i className="material-icons">mode_edit</i>}
|
||||||
/>
|
/>
|
||||||
}
|
|
||||||
{loggedUser.anyOf(visitReporter) &&
|
|
||||||
<MenuItem
|
|
||||||
onTouchTap={(e) => this.handleChange(e, `/app/form/visit/${this.state.useruuid}`)}
|
|
||||||
primaryText="Create Visit"
|
|
||||||
innerDivStyle={listItemStyle}
|
|
||||||
style={{ fontSize: '14px', lineHeight: '48px' }}
|
|
||||||
leftIcon={<i className="material-icons">mode_edit</i>}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onTouchTap={(e) => this.handleChange(e, `/login`)}
|
onTouchTap={(e) => this.handleChange(e, `/login`)}
|
||||||
primaryText="Log Out"
|
primaryText="Log Out"
|
||||||
|
|||||||
@@ -101,10 +101,10 @@ class SidebarContent extends React.Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ul className="nav" ref={(c) => { this.nav = c; }}>
|
<ul className="nav" ref={(c) => { this.nav = c; }}>
|
||||||
{loggedUser.anyOf(visitReporter) &&
|
{loggedUser.anyOf(planScheduler, visitReporter) &&
|
||||||
<li><FlatButton className="prepend-icon" href={"#/app/form/visit/" + this.state.user.useruuid}><span>Create Visit</span></FlatButton></li>
|
<li><FlatButton className="prepend-icon" href={"#/app/form/visit/" + this.state.user.useruuid}><span>Create Visit</span></FlatButton></li>
|
||||||
}
|
}
|
||||||
{!loggedUser.anyOf(visitReporter) &&
|
{!loggedUser.anyOf(planScheduler, visitReporter) &&
|
||||||
<li>
|
<li>
|
||||||
<FlatButton href="#/app/form"><i className="nav-icon material-icons cyan-text text-lighter-4">directions_car</i><span className="nav-text">Rides</span></FlatButton>
|
<FlatButton href="#/app/form"><i className="nav-icon material-icons cyan-text text-lighter-4">directions_car</i><span className="nav-text">Rides</span></FlatButton>
|
||||||
<ul>
|
<ul>
|
||||||
@@ -113,7 +113,7 @@ class SidebarContent extends React.Component {
|
|||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
{!loggedUser.anyOf(visitReporter) &&
|
{!loggedUser.anyOf(planScheduler, visitReporter) &&
|
||||||
<li>
|
<li>
|
||||||
<FlatButton href="#/app/chart"><i className="nav-icon material-icons">people_outline</i><span className="nav-text">Members</span></FlatButton>
|
<FlatButton href="#/app/chart"><i className="nav-icon material-icons">people_outline</i><span className="nav-text">Members</span></FlatButton>
|
||||||
<ul>
|
<ul>
|
||||||
@@ -122,7 +122,6 @@ class SidebarContent extends React.Component {
|
|||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
{!loggedUser.anyOf(visitReporter) &&
|
|
||||||
<li>
|
<li>
|
||||||
<FlatButton href="#/app/chart"><i className="nav-icon material-icons">schedule</i><span className="nav-text">Visits</span></FlatButton>
|
<FlatButton href="#/app/chart"><i className="nav-icon material-icons">schedule</i><span className="nav-text">Visits</span></FlatButton>
|
||||||
<ul>
|
<ul>
|
||||||
@@ -130,9 +129,7 @@ class SidebarContent extends React.Component {
|
|||||||
<li> <FlatButton className="prepend-icon" href="#/app/table/visits"><span className="nav-text">Manage Visits</span></FlatButton></li>
|
<li> <FlatButton className="prepend-icon" href="#/app/table/visits"><span className="nav-text">Manage Visits</span></FlatButton></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
}
|
|
||||||
|
|
||||||
{!loggedUser.anyOf(visitReporter) &&
|
|
||||||
<li>
|
<li>
|
||||||
<FlatButton href="#/app/chart"><i className="nav-icon material-icons">settings</i><span className="nav-text">Manage</span></FlatButton>
|
<FlatButton href="#/app/chart"><i className="nav-icon material-icons">settings</i><span className="nav-text">Manage</span></FlatButton>
|
||||||
<ul>
|
<ul>
|
||||||
@@ -155,7 +152,6 @@ class SidebarContent extends React.Component {
|
|||||||
</li> */}
|
</li> */}
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
}
|
|
||||||
|
|
||||||
<li className="nav-divider" />
|
<li className="nav-divider" />
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const normalizeRoles = (profiles) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (roleKeys.length === 1) {
|
if (roleKeys.length === 1) {
|
||||||
return profiles[roleKeys[0]].roles;
|
return profiles[roleKeys[0]].authorize;
|
||||||
}
|
}
|
||||||
|
|
||||||
const roles = profiles.reduce((result, profile) => {
|
const roles = profiles.reduce((result, profile) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user