diff --git a/lib/components/AuthorizedComponent.react.js b/lib/components/AuthorizedComponent.react.js index ddb7b40..215df57 100644 --- a/lib/components/AuthorizedComponent.react.js +++ b/lib/components/AuthorizedComponent.react.js @@ -38,6 +38,10 @@ class AuthorizedComponent extends React.Component { // @param routeRoles roles defending the route requested // @param userRoles roles of the user accessing the component handleUnauthorizedRole(routeRoles, userRoles) { + if (typeof this.notAuthorizedPath === 'undefined') { + throw new Error('AuthorizedComponent: No not authorized path defined! Please define it in the constructor of your component.'); + } + const { router } = this.context; router.push(this.notAuthorizedPath); } @@ -47,10 +51,6 @@ class AuthorizedComponent extends React.Component { if (typeof this.userRoles === 'undefined') { throw new Error('AuthorizedComponent: No user roles defined! Please define them in the constructor of your component.'); } - - if (typeof this.notAuthorizedPath === 'undefined') { - throw new Error('AuthorizedComponent: No not authorized path defined! Please define it in the constructor of your component.'); - } } }