mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-26 03:14:19 +00:00
Compare commits
2 Commits
551b928dca
...
fc2ace4b9e
Author | SHA1 | Date | |
---|---|---|---|
|
fc2ace4b9e | ||
|
a174bf968f |
@ -1,49 +0,0 @@
|
||||
from flask_login import current_user
|
||||
from flask_socketio import disconnect, Namespace
|
||||
from app import db, hashids
|
||||
from app.decorators import socketio_admin_required
|
||||
from app.models import User
|
||||
|
||||
|
||||
class AdminNamespace(Namespace):
|
||||
def on_connect(self):
|
||||
# Check if the user is authenticated and is an administrator
|
||||
if not (current_user.is_authenticated and current_user.is_administrator):
|
||||
disconnect()
|
||||
|
||||
|
||||
@socketio_admin_required
|
||||
def on_set_user_confirmed(self, user_hashid: str, confirmed_value: bool):
|
||||
# Decode the user hashid
|
||||
user_id = hashids.decode(user_hashid)
|
||||
|
||||
# Validate user_id
|
||||
if not isinstance(user_id, int):
|
||||
return {
|
||||
'code': 400,
|
||||
'body': 'user_id is invalid'
|
||||
}
|
||||
|
||||
# Validate confirmed_value
|
||||
if not isinstance(confirmed_value, bool):
|
||||
return {
|
||||
'code': 400,
|
||||
'body': 'confirmed_value is invalid'
|
||||
}
|
||||
|
||||
# Load user from database
|
||||
user = User.query.get(user_id)
|
||||
if user is None:
|
||||
return {
|
||||
'code': 404,
|
||||
'body': 'User not found'
|
||||
}
|
||||
|
||||
# Update user confirmed status
|
||||
user.confirmed = confirmed_value
|
||||
db.session.commit()
|
||||
|
||||
return {
|
||||
'code': 200,
|
||||
'body': f'User "{user.username}" is now {"confirmed" if confirmed_value else "unconfirmed"}'
|
||||
}
|
@ -70,7 +70,6 @@ class Config:
|
||||
NOPAQUE_ADMIN = os.environ.get('NOPAQUE_ADMIN')
|
||||
NOPAQUE_DATA_DIR = Path(os.environ.get('NOPAQUE_DATA_PATH', '/mnt/nopaque'))
|
||||
NOPAQUE_IS_PRIMARY_INSTANCE = os.environ.get('NOPAQUE_IS_PRIMARY_INSTANCE', 'true').lower() == 'true'
|
||||
NOPAQUE_MAIL_SUBJECT_PREFIX = '[nopaque]'
|
||||
NOPAQUE_SERVICE_DESK = 'gitlab-ub-incoming+sfb1288inf-nopaque-1324-issue-@jura.uni-bielefeld.de' # noqa
|
||||
NOPAQUE_SOCKETIO_MESSAGE_QUEUE_URI = os.environ.get('NOPAQUE_SOCKETIO_MESSAGE_QUEUE_URI')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user