Skip to content

Commit

Permalink
refactor(wrapComponentInAuthStrategy): Relax some admin checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
binh-dam-ibigroup committed Jul 12, 2023
1 parent 184dbbf commit 6ad320a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/common/containers/wrapComponentInAuthStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export default function wrapComponentInAuthStrategy (
): React.Component<AuthWrapperProps> {
const AuthStrategyWrapper = (props: AuthWrapperProps) => {
const { user } = props
const userIsLoggedIn: boolean = AUTH0_DISABLED || !!user.token
const adminTestFailed = !AUTH0_DISABLED && (requireAdmin && !user.isCheckingLogin && !userHasAdminViewPrivileges(user))
const userIsLoggedIn: boolean = !!user.token
const adminTestFailed = requireAdmin && !user.isCheckingLogin && !userHasAdminViewPrivileges(user)
const messages = getComponentMessages('WrapComponentInAuthStrategy')

useEffect(() => {
Expand All @@ -40,7 +40,7 @@ export default function wrapComponentInAuthStrategy (
}
}, [userIsLoggedIn, adminTestFailed])

if (!AUTH0_DISABLED && (requireAuth && !user.token)) {
if (requireAuth && !user.token) {
// Don't render anything while the login info is being fetched (i.e. token is null).
return null
} else if (adminTestFailed) {
Expand Down

0 comments on commit 6ad320a

Please sign in to comment.