summaryrefslogtreecommitdiff
path: root/server/szurubooru/func/auth.py
diff options
context:
space:
mode:
authorrr- <rr-@sakuya.pl>2016-04-29 13:08:41 +0200
committerrr- <rr-@sakuya.pl>2016-04-29 13:16:16 +0200
commitda5b32feebfb84bfaca44f5680819510d8c8fc57 (patch)
tree3bbc800107d0f26202c2415c4da39d17702b6e77 /server/szurubooru/func/auth.py
parentd67a1b2f1c0952f835ef3c89324bbf17a92f2b93 (diff)
server/users: fix hiding email from admins etc
Diffstat (limited to 'server/szurubooru/func/auth.py')
-rw-r--r--server/szurubooru/func/auth.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/server/szurubooru/func/auth.py b/server/szurubooru/func/auth.py
index efdd0d6..8a5edcb 100644
--- a/server/szurubooru/func/auth.py
+++ b/server/szurubooru/func/auth.py
@@ -36,15 +36,16 @@ def is_valid_password(user, password):
]
return valid_hash in possible_hashes
-def verify_privilege(user, privilege_name):
- ''' Throw an AuthError if the given user doesn't have given privilege. '''
+def has_privilege(user, privilege_name):
all_ranks = config.config['ranks']
-
assert privilege_name in config.config['privileges']
assert user.rank in all_ranks
minimal_rank = config.config['privileges'][privilege_name]
good_ranks = all_ranks[all_ranks.index(minimal_rank):]
- if user.rank not in good_ranks:
+ return user.rank in good_ranks
+
+def verify_privilege(user, privilege_name):
+ if not has_privilege(user, privilege_name):
raise errors.AuthError('Insufficient privileges to do this.')
def generate_authentication_token(user):