Skip to content

Commit

Permalink
Merge pull request #88 from knikolla/refactor/binary
Browse files Browse the repository at this point in the history
Refactor: Simplify logic in deleting user
  • Loading branch information
knikolla authored Jan 19, 2023
2 parents 8cfda38 + c33d742 commit aa14fe4
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions acct_mgt/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,7 @@ def create_moc_user(user_name):
@APP.route("/users/<user_name>", methods=["DELETE"])
@AUTH.login_required
def delete_moc_user(user_name):
user_does_not_exist = 0
# use case if User exists then delete
if shift.user_exists(user_name):
if user_exists := shift.user_exists(user_name):
result = shift.delete_user(user_name)
if result.status_code not in (200, 201):
return Response(
Expand All @@ -303,25 +301,19 @@ def delete_moc_user(user_name):
status=400,
mimetype="application/json",
)
else:
user_does_not_exist = 0x01

id_user = user_name

if shift.identity_exists(id_user):
result = shift.delete_identity(id_user)
if identity_exists := shift.identity_exists(user_name):
result = shift.delete_identity(user_name)
if result.status_code not in (200, 201):
return Response(
response=json.dumps(
{"msg": f"unable to delete identity for ({id_user})"}
{"msg": f"unable to delete identity for ({user_name})"}
),
status=400,
mimetype="application/json",
)
else:
user_does_not_exist = user_does_not_exist | 0x02

if user_does_not_exist == 3:
if not (user_exists and identity_exists):
return Response(
response=json.dumps({"msg": f"user does not exist ({user_name})"}),
status=200,
Expand Down

0 comments on commit aa14fe4

Please sign in to comment.