Use get to find role

pull/3492/head
Brandon Farmer 2018-05-21 09:42:58 -07:00
parent ca0d621a0e
commit c4f79044fa
1 changed files with 5 additions and 2 deletions

View File

@ -128,9 +128,12 @@ export class CheckSources extends Component<Props, State> {
const source = sources.find(s => s.id === params.sourceID)
const defaultSource = sources.find(s => s.default === true)
const role = _.get(this.props, 'auth.me.role', '')
const nextRole = _.get(nextProps, 'auth.me.role', '')
if (
isUserAuthorized(this.props.auth.me.role, ADMIN_ROLE) &&
!isUserAuthorized(nextProps.auth.me.role, ADMIN_ROLE)
isUserAuthorized(role, ADMIN_ROLE) &&
!isUserAuthorized(nextRole, ADMIN_ROLE)
) {
return router.push('/')
}