can authorization helper mixing better explanation

This commit is contained in:
2018-01-17 15:05:48 -03:00
parent 39edc6da7f
commit 67fef8e184
+18 -2
View File
@@ -1,9 +1,25 @@
import Ember from 'ember' 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 export default Ember.Helper.extend
globals: Ember.inject.service('globals') 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) -> compute: ([authorization, type, target], options) ->
return false unless @get('globals.current_user') return false unless @get('globals.current_user')
return true if @get('globals.current_user.admin') return true if @get('globals.current_user.admin')