Skip to content

Commit

Permalink
feat: move secret_key creation logic to code (#2118)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmoysrt authored and saurabh6790 committed Sep 2, 2024
1 parent db0b13e commit d601256
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions press/press/doctype/subscription/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ def get_list_query(query, **list_args):

return query.run(as_dict=True)

def before_validate(self):
if not self.secret_key and self.document_type == "Marketplace App":
self.secret_key = frappe.utils.generate_hash(length=40)
if not frappe.db.exists("Site Config Key", {"key": f"sk_{self.document_name}"}):
frappe.get_doc(
doctype="Site Config Key", internal=True, key=f"sk_{self.document_name}"
).insert(ignore_permissions=True)

def validate(self):
self.validate_duplicate()

Expand Down

0 comments on commit d601256

Please sign in to comment.