File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 1+ Auth functions are expected to return a dictionary with a 'success' key,
2+ not raise exceptions.
Original file line number Diff line number Diff line change @@ -12,17 +12,17 @@ def datastore_auth(context: Context,
1212
1313 user = context .get ('user' )
1414
15- authorized = p .toolkit .check_access (privilege , context , data_dict )
16- if not authorized :
15+ try :
16+ p .toolkit .check_access (privilege , context , data_dict )
17+ except p .toolkit .NotAuthorized :
1718 return {
1819 'success' : False ,
1920 'msg' : p .toolkit ._ (
20- 'User {0} not authorized to update resource {1 }'
21- .format (str (user ), data_dict ['id' ])
21+ 'User {0} not authorized to perform {1} on resource {2 }'
22+ .format (str (user ), privilege , data_dict ['id' ])
2223 )
2324 }
24- else :
25- return {'success' : True }
25+ return {'success' : True }
2626
2727
2828def datastore_create (context : Context , data_dict : DataDict ):
You can’t perform that action at this time.
0 commit comments