New assets, fixed list box scrolling, header text, etc..
This commit is contained in:
@@ -62,8 +62,8 @@ export class Login extends Component {
|
||||
api.login(obj.email, obj.password, obj.rememberMe).then((user) => {
|
||||
this.setState({ waitModal: false })
|
||||
if (this.props.history) {
|
||||
const landing = user.role === 'broker' ? '/broker-dashboard' : 'dashboard'
|
||||
let url = new URLSearchParams(window.location.search).get('redirect') || landing
|
||||
let url = new URLSearchParams(window.location.search).get('redirect') || '/'
|
||||
|
||||
try {
|
||||
this.props.history.replace(url)
|
||||
} catch (error) {
|
||||
@@ -73,7 +73,7 @@ export class Login extends Component {
|
||||
}).catch((error) => {
|
||||
this.setState({
|
||||
waitModal: false,
|
||||
messageModal: { icon: 'hold', message: `Unable to login`, detail: error.message }
|
||||
messageModal: { icon: 'hand', message: `Unable to login`, detail: error.message }
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -6,10 +6,11 @@ export class Logout extends React.Component {
|
||||
static propTypes = {
|
||||
history: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
||||
}
|
||||
|
||||
componentDidMount(event) {
|
||||
api.logout().then(() => {
|
||||
if (this.props.history) {
|
||||
this.props.history.push('/')
|
||||
this.props.history.replace('/login')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import { api } from 'src/API'
|
||||
|
||||
export class ProtectedRoute extends React.Component {
|
||||
static propTypes = {
|
||||
roles: PropTypes.array,
|
||||
location: PropTypes.shape({
|
||||
pathname: PropTypes.string,
|
||||
search: PropTypes.string,
|
||||
@@ -41,17 +40,11 @@ export class ProtectedRoute extends React.Component {
|
||||
// The API might be in the middle of fetching the user information
|
||||
// Return something and wait for login evint to fire to re-render
|
||||
return <div />
|
||||
}
|
||||
|
||||
let roles = this.props.roles
|
||||
|
||||
if (roles && roles.includes(user.role)) {
|
||||
} else if (user.administrator) {
|
||||
return <Route {...this.props} />
|
||||
} else {
|
||||
return <Redirect to='/' />
|
||||
}
|
||||
} else {
|
||||
return <Redirect to={`/login?redirect=${this.props.location.pathname}${this.props.location.search}`} />
|
||||
}
|
||||
|
||||
return <Redirect to={`/login?redirect=${this.props.location.pathname}${this.props.location.search}`} />
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user