Skip to content

Commit 182747a

Browse files
committed
Update methods.py
1 parent 9fb8d58 commit 182747a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

licensing/methods.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,6 +1811,38 @@ def get_users(token, customer_id = 0):
18111811

18121812
return (jobj["users"], "")
18131813

1814+
@staticmethod
1815+
def reset_password_token(token, username):
1816+
1817+
"""
1818+
This method allows you to retrive the password reset token that you
1819+
can use when calling Change Password method. Please note that calling
1820+
this method requires a UserAuthAdmin token.
1821+
1822+
More docs: https://app.cryptolens.io/docs/api/v3/ResetPasswordToken
1823+
"""
1824+
1825+
try:
1826+
response = HelperMethods.send_request("/userauth/ResetPasswordToken/",\
1827+
{"token":token,\
1828+
"username":username})
1829+
except HTTPError as e:
1830+
response = e.read()
1831+
except URLError as e:
1832+
return (None, "Could not contact the server. Error message: " + str(e))
1833+
except Exception:
1834+
return (None, "Could not contact the server.")
1835+
1836+
jobj = json.loads(response)
1837+
1838+
if jobj == None or not("result" in jobj) or jobj["result"] == 1:
1839+
if jobj != None:
1840+
return (None, jobj["message"])
1841+
else:
1842+
return (None, "Could not contact the server.")
1843+
1844+
return (jobj["passwordResetToken"], "")
1845+
18141846

18151847
@staticmethod
18161848
def remove_user(token, username):

0 commit comments

Comments
 (0)