Skip to content

Instantly share code, notes, and snippets.

@etozzato
Last active May 31, 2016 15:20
Show Gist options
  • Save etozzato/14c00d4488c42835ba70 to your computer and use it in GitHub Desktop.
Save etozzato/14c00d4488c42835ba70 to your computer and use it in GitHub Desktop.
ACL in EmberJS
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')
@etozzato
Copy link
Author

etozzato commented Jul 3, 2014

the implementation of line 11 is probably only suitable for a 'private access' app, not for the wild ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment