Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#1210] Add auth_user_obj to context in check_access
If not already there or ignore_auth is True, and the context has a user name, try to see if the user actually exists in the DB, and store the object (or None if not found) in context['auth_user_obj']. The check if performed only once per context object.
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,6 +208,15 @@ def check_access(action, context, data_dict=None): | |
user = context.get('user') | ||
log.debug('check access - user %r, action %s' % (user, action)) | ||
|
||
if not 'auth_user_obj' in context: | ||
context['auth_user_obj'] = None | ||
|
||
if not context.get('ignore_auth'): | ||
if not context.get('__auth_user_obj_checked'): | ||
context['__auth_user_obj_checked'] = True | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
if context.get('user') and not context.get('auth_user_obj'): | ||
context['auth_user_obj'] = model.User.by_name(context['user']) | ||
This comment has been minimized.
Sorry, something went wrong.
seanh
Contributor
|
||
|
||
if action: | ||
#if action != model.Action.READ and user in | ||
# (model.PSEUDO_USER__VISITOR, ''): | ||
|
This file contains 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
I'd move this to after the lines below that do the auth user check! :) Not that it should make any difference