fnakstad / angular-client-side-auth

One way to implement authentication/authorization in Angular applications
http://angular-client-side-auth.herokuapp.com/
MIT License
1.63k stars 346 forks source link

Cannot read property 'bitMask' of undefined #41

Closed amanfs closed 10 years ago

amanfs commented 10 years ago

Hey, first of all gotta say I love your method of authentication. I integrated your code, and made a cookie similar to yours

user=%7B%22username%22%3A%22adrian@gmail.com%22%2C%22role%22%3A%7B%22bitMask%22%3A4%2C%22title%22%3A%22admin%22%7D%7D; connect.sess=s%3Aj%3A%7B%22passport%22%3A%7B%7D%7D.Y%2FN8%2F6JZIdX2TJ%2BTKGLvw0Fxbthv7AppwHR0GLB0EpI

But when I try to login in, it breaks at

return accessLevel.bitMask & role.bitMask;

in the service 'Auth' and in the app.js file on the run function

if (!Auth.authorize(next.access)) {
                if(Auth.isLoggedIn()) $location.path('/');
                else                  $location.path('/login');
}

any help would be much appreciated.

screen shot 2013-10-09 at 2 22 38 pm

-Aman

oGLOWo commented 10 years ago

I was just integrating this into my angular app and I came across what seems to be the same error, but I'm not sure. I get to the same location mentioned above by @amanfs in the debugger and at return accessLevel.bitMask, you'll get a type error because accessLevel is undefined at this point. I'm not sure what I'm doing wrong because I haven't really modified anything other than the call to login to change the the path it sends the login data to.

I'm using angular 1.1.5, but I went back to 1.0.7 to see if that was the issue and it's not. It's still throwing the same type error.

Anyone else seeing this? I really want to get this into my app.

fnakstad commented 10 years ago

Hey guys! From the looks of the error trace the problem may be that you have a route in your routing table which doesn't contain the access property. I get the exact same error message if I intentionally remove the access property from a route and try to access it.

If that's not the problem, maybe you could give me access to the code in question so I can reproduce the problem more accurately?