Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Disable Auto Account Approval
Browse files Browse the repository at this point in the history
  • Loading branch information
Sina Jalali authored and Sina Jalali committed Dec 8, 2023
1 parent 88ff721 commit 6de3d65
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,26 +126,27 @@ def login():

# JWT validated, approve account
logger.debug('approving account', account=decoded["sub"])
try:
response = procurement_api.approve_account(decoded["sub"])
logger.info("procurement api approve complete", response={})
if settings.auto_approve_entitlements:
# look for any pending entitlement creation requests and approve them
pending_creation_requests = procurement_api.list_entitlements(account_id=decoded["sub"])
logger.debug("pending requests", pending_creation_requests=pending_creation_requests)
for pcr in pending_creation_requests["entitlements"]:
logger.debug("pending creation request", pcr=pcr)
entitlement_id = procurement_api.get_entitlement_id(pcr["name"])
logger.info("approving entitlement", entitlement_id=entitlement_id)
procurement_api.approve_entitlement(decoded["sub"], entitlement_id)
page_context = {
"data": decoded
}
return "Your account has been approved. You can close this window.", 200
return "Your account is not approved yet :)", 200
# try:
# response = procurement_api.approve_account(decoded["sub"])
# logger.info("procurement api approve complete", response={})
# if settings.auto_approve_entitlements:
# # look for any pending entitlement creation requests and approve them
# pending_creation_requests = procurement_api.list_entitlements(account_id=decoded["sub"])
# logger.debug("pending requests", pending_creation_requests=pending_creation_requests)
# for pcr in pending_creation_requests["entitlements"]:
# logger.debug("pending creation request", pcr=pcr)
# entitlement_id = procurement_api.get_entitlement_id(pcr["name"])
# logger.info("approving entitlement", entitlement_id=entitlement_id)
# procurement_api.approve_entitlement(decoded["sub"], entitlement_id)
# page_context = {
# "data": decoded
# }
# return "Your account has been approved. You can close this window.", 200
# return render_template("register.html", **page_context)
except Exception as e:
logger.error("an exception occurred approving accounts", exception=traceback.format_exc())
return {"error": "failed to approve account"}, 500
# except Exception as e:
# logger.error("an exception occurred approving accounts", exception=traceback.format_exc())
# return {"error": "failed to approve account"}, 500


@app.route("/test/register", methods=["GET"])
Expand Down

0 comments on commit 6de3d65

Please sign in to comment.