k4ever/k4ever/main/helper.py

22 lines
682 B
Python

# This file is part of k4ever, a point-of-sale system
# Contact............ <k4ever@lists.someserver.de>
# Website............ http://k4ever.someserver.de/
# Bug tracker........ http://k4ever.someserver.de/report
#
# Licensed under GNU Affero General Public License v3 or later
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