cahnges to the user management

This commit is contained in:
2026-08-25 12:50:34 +02:00
parent ac9fa27db8
commit 7aeb325d4e
4 changed files with 261 additions and 133 deletions
+48 -1
View File
@@ -174,4 +174,51 @@ def update_password(username, new_password):
return result.modified_count > 0
except Exception as e:
print(f"Error updating password: {e}")
return False
return False
def email_exists(email):
"""
Prüft, ob die E-Mail bereits von einem verifizierten Konto genutzt wird.
"""
client = None
try:
client, users = _get_users_collection()
user = users.find_one({'email': email.strip().lower(), 'verified': True})
return user is not None
finally:
if client:
client.close()
def update_verification_token(username, new_token):
"""
Aktualisiert den Verifizierungs-Token für einen Benutzer.
"""
client = None
try:
client, users = _get_users_collection()
hashed_token = hashing(new_token)
result = users.update_one(
{'Username': username},
{'$set': {'verification_token': hashed_token}}
)
return result.modified_count > 0
finally:
if client:
client.close()
def update_user_email_and_token(username, new_email, new_token):
"""
Aktualisiert die E-Mail-Adresse und den Verifizierungs-Token für einen Benutzer.
"""
client = None
try:
client, users = _get_users_collection()
hashed_token = hashing(new_token)
result = users.update_one(
{'Username': username},
{'$set': {'email': new_email.strip().lower(), 'verification_token': hashed_token}}
)
return result.modified_count > 0
finally:
if client:
client.close()