Spaces:
Sleeping
Sleeping
GeraldoRiberia commited on
Commit ·
e448396
1
Parent(s): 1949831
login + zoom out fix
Browse files
server.py
CHANGED
|
@@ -17,7 +17,7 @@ import hashlib
|
|
| 17 |
import math
|
| 18 |
from pydantic import BaseModel, Field
|
| 19 |
from pymongo import AsyncMongoClient
|
| 20 |
-
|
| 21 |
from jose import JWTError, jwt
|
| 22 |
from dotenv import load_dotenv
|
| 23 |
from pathlib import Path
|
|
@@ -86,7 +86,7 @@ audio_recordings_collection = None
|
|
| 86 |
audio_settings_collection = None
|
| 87 |
audio_angles_collection = None
|
| 88 |
|
| 89 |
-
|
| 90 |
|
| 91 |
# JWT Configuration
|
| 92 |
SECRET_KEY = os.getenv(
|
|
@@ -126,15 +126,11 @@ def normalize_email(email: str) -> str:
|
|
| 126 |
|
| 127 |
|
| 128 |
def get_password_hash(password: str) -> str:
|
| 129 |
-
|
| 130 |
-
password_hash = hashlib.sha256(password.encode('utf-8')).digest()
|
| 131 |
-
return pwd_context.hash(password_hash)
|
| 132 |
|
| 133 |
|
| 134 |
def verify_password(plain_password: str, hashed_password: str) -> bool:
|
| 135 |
-
|
| 136 |
-
password_hash = hashlib.sha256(plain_password.encode('utf-8')).digest()
|
| 137 |
-
return pwd_context.verify(password_hash, hashed_password)
|
| 138 |
|
| 139 |
|
| 140 |
def require_users_collection():
|
|
|
|
| 17 |
import math
|
| 18 |
from pydantic import BaseModel, Field
|
| 19 |
from pymongo import AsyncMongoClient
|
| 20 |
+
import bcrypt
|
| 21 |
from jose import JWTError, jwt
|
| 22 |
from dotenv import load_dotenv
|
| 23 |
from pathlib import Path
|
|
|
|
| 86 |
audio_settings_collection = None
|
| 87 |
audio_angles_collection = None
|
| 88 |
|
| 89 |
+
|
| 90 |
|
| 91 |
# JWT Configuration
|
| 92 |
SECRET_KEY = os.getenv(
|
|
|
|
| 126 |
|
| 127 |
|
| 128 |
def get_password_hash(password: str) -> str:
|
| 129 |
+
return bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()).decode('utf-8')
|
|
|
|
|
|
|
| 130 |
|
| 131 |
|
| 132 |
def verify_password(plain_password: str, hashed_password: str) -> bool:
|
| 133 |
+
return bcrypt.checkpw(plain_password.encode('utf-8'), hashed_password.encode('utf-8'))
|
|
|
|
|
|
|
| 134 |
|
| 135 |
|
| 136 |
def require_users_collection():
|