can authorization helper mixing better explanation
This commit is contained in:
@@ -1,9 +1,25 @@
|
||||
import Ember from 'ember'
|
||||
# Example usage
|
||||
# <ember-app>/app/helpers/can.coffee
|
||||
#
|
||||
# import DunlopCan from 'ember-cli-dunlop/helpers/dunlop-can'
|
||||
#
|
||||
# export default DunlopCan.extend
|
||||
# # allow all epots scoped model on read adpter permission
|
||||
# custom_compute: (permission, type, target, roles) ->
|
||||
# if permission is 'read' and type is 'model' and target.match(/^epots/)
|
||||
# return 'read-adapter-epots' in roles
|
||||
# false
|
||||
#
|
||||
|
||||
export default Ember.Helper.extend
|
||||
globals: Ember.inject.service('globals')
|
||||
custom_compute: (authorization, type, target, roles) ->
|
||||
false
|
||||
|
||||
# This method is meant to be overloaded for custom authorization hehaviour
|
||||
custom_compute: (authorization, type, target, roles) -> false
|
||||
|
||||
# compute implements the standard dunlop checks. Application specific logic should be implemented
|
||||
# in the custom_compute method
|
||||
compute: ([authorization, type, target], options) ->
|
||||
return false unless @get('globals.current_user')
|
||||
return true if @get('globals.current_user.admin')
|
||||
|
||||
Reference in New Issue
Block a user