fix add role to user
This commit is contained in:
parent
5bab4a7cde
commit
d7428b2ed1
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue