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 Aug 30, 2024
1 parent 6e606c6 commit 84b20e3
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 @@ -85,6 +85,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 84b20e3

Please sign in to comment.