Last active
May 31, 2016 15:20
-
-
Save etozzato/14c00d4488c42835ba70 to your computer and use it in GitHub Desktop.
ACL in EmberJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FakeApp.Admin.ACL = Ember.Mixin.create | |
# How to USE ACL | |
# pass the mixin as first parameter of the route extend method and | |
# define the roles that are allowed | |
# | |
# ApplicationRoute = Ember.Route.extend FakeApp.Admin.ACL, | |
# roles: ['superuser', 'recruiter'] | |
beforeModel: (transition) -> | |
return if 'unauthorized' == transition.targetName | |
@_super() | |
if @get('roles') && !@get('roles').contains(FakeApp.User.current_role) | |
transition.abort() | |
@transitionTo('unauthorized') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the implementation of line 11 is probably only suitable for a 'private access' app, not for the wild ;)