Added helper for Authblob

This commit is contained in:
Sebastian Lohff 2011-11-04 17:34:13 +01:00
parent e87b8e6ca1
commit c0e9f81bf0
1 changed files with 14 additions and 0 deletions

14
k4ever/main/helper.py Normal file
View File

@ -0,0 +1,14 @@
from main.models import PluginPermission
def getUserFromAuthblob(authblob, plugin, splitBy="\n"):
""" Return user, if found, for an authblob, else None. """
if authblob == '':
return None
perms = PluginPermission.objects.filter(plugin=plugin, authblob__contains=authblob)
for perm in perms:
print perm
if authblob in perm.authblob.split(splitBy):
return perm.user
return None