Update modules/database.py
Browse files- modules/database.py +4 -1
modules/database.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
# database.py
|
| 2 |
-
import bcrypt
|
| 3 |
import logging
|
| 4 |
import os
|
| 5 |
from azure.cosmos import CosmosClient
|
|
@@ -9,6 +8,8 @@ import certifi
|
|
| 9 |
from datetime import datetime
|
| 10 |
import io
|
| 11 |
import base64
|
|
|
|
|
|
|
| 12 |
|
| 13 |
logging.basicConfig(level=logging.DEBUG)
|
| 14 |
logger = logging.getLogger(__name__)
|
|
@@ -74,7 +75,9 @@ def initialize_mongodb_connection():
|
|
| 74 |
#######################################################################################################
|
| 75 |
def create_user(username, password, role):
|
| 76 |
try:
|
|
|
|
| 77 |
hashed_password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()).decode('utf-8')
|
|
|
|
| 78 |
user_data = {
|
| 79 |
'id': username,
|
| 80 |
'password': hashed_password,
|
|
|
|
| 1 |
# database.py
|
|
|
|
| 2 |
import logging
|
| 3 |
import os
|
| 4 |
from azure.cosmos import CosmosClient
|
|
|
|
| 8 |
from datetime import datetime
|
| 9 |
import io
|
| 10 |
import base64
|
| 11 |
+
import bcrypt
|
| 12 |
+
print(f"Bcrypt version: {bcrypt.__version__}")
|
| 13 |
|
| 14 |
logging.basicConfig(level=logging.DEBUG)
|
| 15 |
logger = logging.getLogger(__name__)
|
|
|
|
| 75 |
#######################################################################################################
|
| 76 |
def create_user(username, password, role):
|
| 77 |
try:
|
| 78 |
+
print(f"Attempting to create user: {username} with role: {role}")
|
| 79 |
hashed_password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()).decode('utf-8')
|
| 80 |
+
print(f"Password hashed successfully for user: {username}")
|
| 81 |
user_data = {
|
| 82 |
'id': username,
|
| 83 |
'password': hashed_password,
|