summaryrefslogtreecommitdiffstats
path: root/module/web/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/web/utils.py')
-rw-r--r--module/web/utils.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/module/web/utils.py b/module/web/utils.py
index b99736216..39ddb361f 100644
--- a/module/web/utils.py
+++ b/module/web/utils.py
@@ -52,6 +52,7 @@ def parse_permissions(session):
return perms
+
def get_permission(perms, p):
perms["add"] = has_permission(p, PERMS.ADD)
perms["delete"] = has_permission(p, PERMS.DELETE)
@@ -59,7 +60,7 @@ def get_permission(perms, p):
perms["see_downloads"] = has_permission(p, PERMS.SEE_DOWNLOADS)
perms["download"] = has_permission(p, PERMS.DOWNLOAD)
perms["settings"] = has_permission(p, PERMS.SETTINGS)
- perms["filemanager"] = has_permission(p, PERMS.FILEMANAGER)
+ perms["accounts"] = has_permission(p, PERMS.ACCOUNTS)
def set_permission(perms):
permission = 0
@@ -75,11 +76,24 @@ def set_permission(perms):
permission |= PERMS.DOWNLOAD
if perms["settings"]:
permission |= PERMS.SETTINGS
- if perms["filemanager"]:
- permission |= PERMS.FILEMANAGER
+ if perms["accounts"]:
+ permission |= PERMS.ACCOUNTS
return permission
+
+def set_session(request, info):
+ s = request.environ.get('beaker.session')
+ s["authenticated"] = True
+ s["user_id"] = info["id"]
+ s["name"] = info["name"]
+ s["role"] = info["role"]
+ s["perms"] = info["permission"]
+ s["template"] = info["template"]
+ s.save()
+
+ return s
+
def parse_userdata(session):
return {"name": session.get("name", "Anonymous"),
"is_admin": True if session.get("role", 1) == 0 else False,