Skip to content

Commit

Permalink
Merge pull request frappe#22538 from ankush/delete_oauth_data
Browse files Browse the repository at this point in the history
refactor: delete oauth internal data with db query
  • Loading branch information
ankush committed Sep 25, 2023
2 parents 36b1a83 + 4fb0f9f commit 2056b0a
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions frappe/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,20 +539,8 @@ def calculate_at_hash(access_token, hash_alg):


def delete_oauth2_data():
# Delete Invalid Authorization Code and Revoked Token
commit_code, commit_token = False, False
code_list = frappe.get_all("OAuth Authorization Code", filters={"validity": "Invalid"})
token_list = frappe.get_all("OAuth Bearer Token", filters={"status": "Revoked"})
if len(code_list) > 0:
commit_code = True
if len(token_list) > 0:
commit_token = True
for code in code_list:
frappe.delete_doc("OAuth Authorization Code", code["name"])
for token in token_list:
frappe.delete_doc("OAuth Bearer Token", token["name"])
if commit_code or commit_token:
frappe.db.commit()
frappe.db.delete("OAuth Authorization Code", {"validity": "Invalid"})
frappe.db.delete("OAuth Bearer Token", {"status": "Revoked"})


def get_client_scopes(client_id):
Expand Down

0 comments on commit 2056b0a

Please sign in to comment.