test2 / modules /auth.py
AIdeaText's picture
Update modules/auth.py
ec3126a verified
raw
history blame
999 Bytes
# /modules/auth.py
from modules.db_connection import call_azure_function
def register_user(username, password, role):
try:
result = call_azure_function('insert_user', {
'username': username,
'password': password,
'role': role
})
return True
except Exception as e:
print(f"Error registering user: {str(e)}")
return False
def authenticate_user(username, password):
try:
result = call_azure_function('get_user', {
'username': username,
'password': password
})
return bool(result)
except Exception as e:
print(f"Error authenticating user: {str(e)}")
return False
def get_user_role(username):
try:
result = call_azure_function('get_user', {
'username': username
})
return result['role'] if result else None
except Exception as e:
print(f"Error getting user role: {str(e)}")
return None