diff --git a/login/app.py b/login/app.py index 183ec0794bdff1642d2d0a2935983ac8e60cae5a..6de4c7672ab26ddd35b3b2f9325ff8956ec7a36b 100644 --- a/login/app.py +++ b/login/app.py @@ -170,25 +170,24 @@ def setrole(email, app_slug, role): :param app_slug: Slug name of the app, for example 'nextcloud' :param role: Role to assign. currently only 'admin', 'user' """ - + app.logger.info(f"Assiging role {role} to {email} for app {app_slug}") # Find user user = KratosUser.find_by_email(KRATOS_ADMIN, email) - if role != 'admin' and role != 'user': + if role not in ('admin', 'user'): print("At this point only the roles 'admin' and 'user' are accepted") - sys.exit(1) - + return if not user: print("User not found. Abort") - sys.exit(1) + return app_obj = db.session.query(App).filter(App.slug==app_slug).first() if not app_obj: print("App not found. Abort.") - sys.exit(1) + return role_obj = db.session.query(AppRole).\ filter(AppRole.app_id==app_obj.id).\