Skip to content

Commit

Permalink
[#2375] change auth function for create_resource so can add as non user
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Jun 21, 2012
1 parent b3e7661 commit 7abf9c6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ckan/logic/auth/create.py
Expand Up @@ -32,12 +32,17 @@ def resource_create(context, data_dict):
# check users eligibility to add resource to package here.
model = context['model']
user = context['user']
userobj = model.User.get(user)
check1 = logic.check_access_old(model.System(), model.Action.PACKAGE_CREATE, context)

if userobj:
return {'success': True}
return {'success': False,
'msg': _('You must be logged in to create a resource')}
if not check1:
return {'success': False, 'msg': _('User %s not authorized to create packages') % str(user)}
else:

check2 = _check_group_auth(context,data_dict)
if not check2:
return {'success': False, 'msg': _('User %s not authorized to edit these groups') % str(user)}

return {'success': True}

def package_relationship_create(context, data_dict):
model = context['model']
Expand Down

0 comments on commit 7abf9c6

Please sign in to comment.