Coder Social home page Coder Social logo

Comments (10)

fnakstad avatar fnakstad commented on July 30, 2024

Hi Rob! Sorry my reply is so late.
This seems like unintended behavior, so I'll take a look at it this weekend. Thanks for reporting :)

from angular-client-side-auth.

mprzydatek avatar mprzydatek commented on July 30, 2024

Hi - i noticed the same behavior, the order of declaring roles in access levels is important. This is because the buildAccessLevels function defined in routingConfig is (incorrectly) taking the last role declared when setting up the "title" attributes. What's more important, because the Auth.isLoggedIn() method is making decisions based on titles comparisons, it is allowing users with the "user" access level, to enter resources as if they had "admin" role (at least in the original code that resides in the repo, at the time of writing this). Nevertheless, great job with coming up with the concept for client-side auth. Cheers.

from angular-client-side-auth.

fnakstad avatar fnakstad commented on July 30, 2024

Thanks for the detailed analysis! I've been busy working on the ui-router migration lately, but since this seems like a really serious bug I'll get on this right away.

from angular-client-side-auth.

iotaweb avatar iotaweb commented on July 30, 2024

Thanks Frederick! One question, in my app I now have the following roles:

roles: [
    'public',
    'user',           
    'userpro',
    'users',            
    'admin'
]

... and access levels:

accessLevels: {
    'public': '*',
    'anon': ['public'],
    'user': ['user'],
    'userpro': ['userpro'],
    'users': ['user', 'userpro', 'admin'],
    'admin': ['admin']
}

As you can see, the title for one of my access levels is users which is not actually a role. So will your fix return the key for the title as opposed to one of the roles as it currently does? (hope this makes sense).

Cheers, Rob

from angular-client-side-auth.

fnakstad avatar fnakstad commented on July 30, 2024

Yes, that was my initial thought. However, upon closer inspection I think I might delete the title property completely from the accessLevels object. The "title" property mprzydatek mentioned (the one used in the "isLoggedIn" function of the Auth service) is actually not from the accessLevels object but from the userRoles object. The title property of the userRoles object is set correctly, so it seems we don't have a bug here after all. So the "title" property of the accessLevels object was added as a mistake as there is no use for it in any of the other services or directives. I will push out a new commit removing title from the generated accessLevels in a few minutes. That is unless you guys see a good use for it in your own applications.

Oh, and so sorry for neglecting this issue for so long Rob. It flew off my radar since I was busy with other things, so I'm very sorry it took so long.

from angular-client-side-auth.

iotaweb avatar iotaweb commented on July 30, 2024

Hah, you're right - I checked my code and I only use role.title in my app! So I have no objections to removing the Access Level title property (unless someone else is using it). And no worries about the delay, it hasn't held me up a bit - just noticed it in passing :)

BTW - this repo is proving very useful for me - have integrated with Hapi.js and using Stormpath for user account management. Your cookie on load to set the user role is inspired!

from angular-client-side-auth.

fnakstad avatar fnakstad commented on July 30, 2024

Happy to hear that :) Let me know if/when your project is up and publicly available!

from angular-client-side-auth.

mprzydatek avatar mprzydatek commented on July 30, 2024

role title is still being used in Auth service (isLoggedIn function).

from angular-client-side-auth.

fnakstad avatar fnakstad commented on July 30, 2024

Yes, but the title property used is that of the userRoles object, not the accessLevels object. The titles are calculated correctly for the userRoles object, so this is not a problem. The original problem here was that for some reason accessLevels also received a title property (which was calculated incorrectly) when there is no tangible use for a title property on the accessLevels object. This is the title property that as removed in the commit I mentioned.

from angular-client-side-auth.

mprzydatek avatar mprzydatek commented on July 30, 2024

OK, got it. Thanks Frederik. Take care.

from angular-client-side-auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.