aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authordesvox <ofunknowndescent@gmail.com>2018-08-05 19:13:41 -0500
committerdesvox <ofunknowndescent@gmail.com>2018-08-05 19:13:41 -0500
commitcba92412a82f0737cf2517412fabb825ed133ccb (patch)
tree114524ff407d6e77bce91c10515b909714e5604b /src
parent826c13db98e79e182e4e9106678a934b71d2241d (diff)
downloadbbj-cba92412a82f0737cf2517412fabb825ed133ccb.tar.gz
Allow setting server admins from server's config.json
Diffstat (limited to 'src')
-rw-r--r--src/db.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/db.py b/src/db.py
index ff4fc3e..a5dcf08 100644
--- a/src/db.py
+++ b/src/db.py
@@ -411,6 +411,21 @@ def user_update(connection, user_object, parameters):
return user_resolve(connection, user_id)
+def set_admins(connection, users):
+ """
+ Set the server admins to be the content of `users`.
+ Any other users that previously had admin rights
+ not included in `users` will have their privledge
+ revoked.
+ """
+ connection.execute("UPDATE users SET is_admin = 0")
+ for user in users:
+ connection.execute(
+ "UPDATE users SET is_admin = 1 WHERE user_name = ?",
+ (user,))
+ connection.commit()
+
+
def user_externalize(user_object):
"""
Cleanse private/internal data from a user object
Un proyecto texto-plano.xyz