Merge branch 'master' into suspect-word-flag-reason

This commit is contained in:
Wyatt Johnson
2017-02-23 14:11:21 -07:00
committed by GitHub
2 changed files with 6 additions and 2 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ const checkLoginFailure = error => ({type: actions.CHECK_LOGIN_FAILURE, error});
export const checkLogin = () => dispatch => {
dispatch(checkLoginRequest());
coralApi('/auth')
return coralApi('/auth')
.then(result => {
const isAdmin = !!result.user.roles.filter(i => i === 'ADMIN').length;
dispatch(checkLoginSuccess(result.user, isAdmin));
@@ -8,7 +8,11 @@ import {PermissionRequired} from '../components/PermissionRequired';
class LayoutContainer extends Component {
componentWillMount () {
const {checkLogin} = this.props;
checkLogin();
checkLogin().then(() => {
if (!this.props.auth.isAdmin) {
location.href = '/admin/login';
}
});
}
render () {
const {isAdmin, loggedIn, loadingUser} = this.props.auth;