From 30a5e417eb9cee3a7b1d60c7e4fc75c4aa94c8a9 Mon Sep 17 00:00:00 2001 From: vikynoah Date: Thu, 26 Jun 2025 14:49:56 +0200 Subject: [PATCH] feat: User Password change ticket (#54) --- creyPY/services/auth0/utils.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/creyPY/services/auth0/utils.py b/creyPY/services/auth0/utils.py index 20e16bd..0e6d7d9 100644 --- a/creyPY/services/auth0/utils.py +++ b/creyPY/services/auth0/utils.py @@ -145,3 +145,20 @@ def password_change_mail(email: str) -> bool: if re.status_code != 200: raise HTTPException(re.status_code, re.json()) return True + +def user_password_change_ticket(user_id: str) -> str: + re = requests.post( + f"https://{AUTH0_DOMAIN}/api/v2/tickets/password-change", + headers={"Authorization": f"Bearer {get_management_token()}"}, + json={ + "user_id":user_id, + "client_id": AUTH0_CLIENT_ID, + "ttl_sec": 0, + "mark_email_as_verified": False, + "includeEmailInRedirect": False + }, + timeout=5, + ) + if re.status_code != 201: + raise HTTPException(re.status_code, re.json()) + return re.json()['ticket']