diff --git a/areas/users/user_service.py b/areas/users/user_service.py index a972d86..eb185c7 100644 --- a/areas/users/user_service.py +++ b/areas/users/user_service.py @@ -48,8 +48,9 @@ class UserService: KratosApi.put("/identities/{}".format(id), kratos_data) app_role = AppRole.query.filter_by(user_id=id).first() - app_role.role_id = data["role_id"] if "role_id" in data else None - db.session.commit() + if app_role: + app_role.role_id = data["role_id"] if "role_id" in data else None + db.session.commit() return UserService.get_user(id)