Skip to content

Commit

Permalink
update status_codes for pending etc
Browse files Browse the repository at this point in the history
  • Loading branch information
daisieh committed Jan 17, 2025
1 parent 5ea3af0 commit 5252411
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/authx/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,16 +743,21 @@ def add_pending_user_to_opa(user_token):
if user_name is None:
return {"error": "Could not verify jwt or obtain user ID"}, 403

if user_name in response["pending_users"]:
# return 200 to indicate OK but nothing was added
return {"message": f"User {user_name} already pending"}, 200

user_dict = {
"userinfo": {
"user_name": user_name,
"sample_jwt": user_token
}
}

response["pending_users"][user_name] = user_dict

response, status_code = set_service_store_secret("opa", key=f"pending_users", value=json.dumps(response))
if status_code == 200:
return response, 201 # 201 created, to indicate that we added the user
return response, status_code


Expand Down

0 comments on commit 5252411

Please sign in to comment.