From c0e9f81bf0db5659cd9dc383642ee46ff75528ce Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Fri, 4 Nov 2011 17:34:13 +0100 Subject: [PATCH] Added helper for Authblob --- k4ever/main/helper.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 k4ever/main/helper.py diff --git a/k4ever/main/helper.py b/k4ever/main/helper.py new file mode 100644 index 0000000..2e58b4d --- /dev/null +++ b/k4ever/main/helper.py @@ -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 +