Skip to content
This repository was archived by the owner on Aug 30, 2021. It is now read-only.

Commit bfcfb55

Browse files
committed
fix(core): Client routes guest access bug
Adds a check for the existence of the "guest" role in the state configuration that we're transitioning to, in the core $stateChangeStart event handler. If it exists, then we allow access. Also, added validation of Authentication.user object. While writing tests, I ran into an issue here when the Authentication service wasn't injected into a controller. Probably best to have this check in place. Fixes #1098
1 parent b12be5f commit bfcfb55

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

modules/core/client/app/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ angular.module(ApplicationConfiguration.applicationModuleName).run(function ($ro
1919
if (toState.data && toState.data.roles && toState.data.roles.length > 0) {
2020
var allowed = false;
2121
toState.data.roles.forEach(function (role) {
22-
if (Authentication.user.roles !== undefined && Authentication.user.roles.indexOf(role) !== -1) {
22+
if ((role === 'guest') || (Authentication.user && Authentication.user.roles !== undefined && Authentication.user.roles.indexOf(role) !== -1)) {
2323
allowed = true;
2424
return true;
2525
}

0 commit comments

Comments
 (0)