From d7428b2ed1ba265b750561b3bfc80b19d629ca11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 9 May 2023 21:59:15 +0200 Subject: [PATCH] fix add role to user --- flaschengeist/plugins/users/cli.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/flaschengeist/plugins/users/cli.py b/flaschengeist/plugins/users/cli.py index 5e69d91..8f8589a 100644 --- a/flaschengeist/plugins/users/cli.py +++ b/flaschengeist/plugins/users/cli.py @@ -3,6 +3,7 @@ import sqlalchemy.exc from flask.cli import with_appcontext from werkzeug.exceptions import NotFound +from flaschengeist import logger from flaschengeist.database import db from flaschengeist.controller import roleController, userController @@ -70,12 +71,19 @@ def user(add_role, delete, user): if USER_KEY in ctx.meta: userController.register(ctx.meta[USER_KEY], ctx.meta[USER_KEY]["password"]) else: + if not isinstance(user, list) or not isinstance(user, tuple): + user = [user] for uid in user: + logger.debug(f"Userid: {uid}") user = userController.get_user(uid) + logger.debug(f"User: {user}") if delete: + logger.debug(f"Deleting user {user}") userController.delete_user(user) elif add_role: + logger.debug(f"Adding role {add_role} to user {user}") role = roleController.get(add_role) + logger.debug(f"Role: {role}") user.roles_.append(role) userController.modify_user(user, None) db.session.commit()