This repository has been archived by the owner on Aug 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2k
Guest role added to State doesn't allow guest access #1098
Comments
mleanos
added a commit
to mleanos/mean
that referenced
this issue
Dec 30, 2015
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 meanjs#1098
lupinthethirdgentleman
pushed a commit
to lupinthethirdgentleman/mean-dashboard
that referenced
this issue
Aug 5, 2021
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 meanjs/mean#1098
This was referenced Apr 7, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When adding the
guest
role to any client route'sdata.roles
array, it doesn't have any effect on the resolving of that route; the route is inaccessible to the unauthenticated user.To reproduce, just add the following to this route config articles.client.routes
Currently, this route is accessible to unauthenticated user because of how the core client app init $stateChangeStart is working.
It doesn't take into account that when the
toState.data.roles
has length, but there's no authenticated user. It just continues processing and never checks for guest access.I realize that if a client route has guest access, then the
data.roles
probably wouldn't have any other roles defined; and most likely, it would not have this setting on the route. However, this is still a bug because of the intended use ofdata.roles
is to allow complete flexibility,& the developer should have complete control.One should be able to define a client route with
data.roles = ['user', 'admin', 'guest']
, or any combination that suits their needs.The simple fix is to add
|| role === 'guest'
to the $stateChangeStart code like so, and should satisfy this bug..The text was updated successfully, but these errors were encountered: