reset endpoint + frontend reset and login pages add
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import hashlib
|
||||
import secrets
|
||||
import string
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from uuid import uuid4
|
||||
|
||||
@@ -22,6 +24,16 @@ class HashService:
|
||||
|
||||
def token_to_hash(self, token:str)->str:
|
||||
return hashlib.sha256(token.encode("utf-8")).hexdigest()
|
||||
|
||||
async def generate_temp_password(self, length:int=16)->str:
|
||||
SPECIAL = "$@#%!^&*()-_+=[]{}"
|
||||
groups = [string.ascii_uppercase, string.ascii_lowercase, string.digits, SPECIAL]
|
||||
chars = [secrets.choice(g) for g in groups] # по одному из каждой группы
|
||||
pool = "".join(groups)
|
||||
chars += [secrets.choice(pool) for _ in range(length - len(chars))]
|
||||
secrets.SystemRandom().shuffle(chars) # чтобы спецсимвол не всегда стоял первым
|
||||
return "".join(chars)
|
||||
|
||||
|
||||
|
||||
'''jwt'''
|
||||
|
||||
Reference in New Issue
Block a user