From 732555ac6ad7151bb7b21395057f4360eb16720e Mon Sep 17 00:00:00 2001 From: Davor Date: Thu, 19 May 2022 19:01:26 +0200 Subject: [PATCH] MR comments --- areas/users/user_service.py | 9 +++------ areas/users/users.py | 13 +++++-------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/areas/users/user_service.py b/areas/users/user_service.py index 0d8c4e3..d394460 100644 --- a/areas/users/user_service.py +++ b/areas/users/user_service.py @@ -71,12 +71,9 @@ class UserService: @staticmethod def delete_user(id): app_role = AppRole.query.filter_by(user_id=id).all() - try: - for ar in app_role: - db.session.delete(ar) - db.session.commit() - except: - raise Exception('Exception during user roles deletion for userId: {}').__format__(id) + for ar in app_role: + db.session.delete(ar) + db.session.commit() @staticmethod def __insertAppRoleToUser(userId, userRes): diff --git a/areas/users/users.py b/areas/users/users.py index 65f0ca1..d472ed6 100644 --- a/areas/users/users.py +++ b/areas/users/users.py @@ -50,11 +50,8 @@ def put_user(id): @jwt_required() @cross_origin() def delete_user(id): - try: - res = KratosApi.delete("/identities/{}".format(id)) - if res.status_code == 204: - UserService.delete_user(id) - return jsonify(), res.status_code - return jsonify(res.json()), res.status_code - except: - return jsonify({"message":"There was an error deleting user"}), 404 + res = KratosApi.delete("/identities/{}".format(id)) + if res.status_code == 204: + UserService.delete_user(id) + return jsonify(), res.status_code + return jsonify(res.json()), res.status_code