Skip to content

Commit

Permalink
[#2939] Auth get_user_id_for_username helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Oct 2, 2012
1 parent 545d8d6 commit efbef7d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ckan/new_authz.py
Expand Up @@ -27,6 +27,17 @@ def is_authorized(action, context,data_dict=None):
else:
raise ValueError(_('Authorization function not found: %s' % action))


def get_user_id_for_username(user_name, allow_none=False):
''' Helper function to get user id '''
# first check if we have the user object already and get from there
if c.userobj and c.userobj.name == user_name:
return c.userobj.id
# FIXME needs completing for if we have no user in session
if allow_none:
return None
raise Exception('Not logged in user')

def _get_auth_function(action, profile=None):
from pylons import config

Expand Down

0 comments on commit efbef7d

Please sign in to comment.