Public Access
des modifications spécifiques sur les droits des utilisateurs
Build and Push Docker Image / build-and-push (push) Successful in 34s
Build and Push Docker Image / build-and-push (push) Successful in 34s
This commit is contained in:
1 parent
b5926633a3
commit
e82a23988b
4 files changed
+134
-1
No files matched your search
@@ -0,0 +1,48 @@
|
||||
import os
|
||||
import json
|
||||
from modules.auth_manager import hasher_mot_de_passe, verifier_mot_de_passe
|
||||
|
||||
USERS_FILE = "/DATA/AppData/MULTI-IA-AETHAS38/users.json"
|
||||
|
||||
def init_users():
|
||||
if not os.path.exists(USERS_FILE):
|
||||
default_users = {
|
||||
"xavier": {
|
||||
"email": "admin@mail.aethas38.duckdns.org",
|
||||
"password_hash": hasher_mot_de_passe("Xavier2026!"),
|
||||
"role": "Super Admin"
|
||||
},
|
||||
"celine": {
|
||||
"email": "cnoirard@ac-lyon.fr",
|
||||
"password_hash": hasher_mot_de_passe("Celine2026!"),
|
||||
"role": "Admin"
|
||||
}
|
||||
}
|
||||
os.makedirs(os.path.dirname(USERS_FILE), exist_ok=True)
|
||||
with open(USERS_FILE, 'w', encoding='utf-8') as f:
|
||||
json.dump(default_users, f, indent=4)
|
||||
|
||||
def load_users():
|
||||
init_users()
|
||||
with open(USERS_FILE, 'r', encoding='utf-8') as f:
|
||||
return json.load(f)
|
||||
|
||||
def save_users(users):
|
||||
with open(USERS_FILE, 'w', encoding='utf-8') as f:
|
||||
json.dump(users, f, indent=4)
|
||||
|
||||
def changer_nom_utilisateur(ancien_nom, nouveau_nom):
|
||||
users = load_users()
|
||||
if ancien_nom in users and nouveau_nom not in users:
|
||||
users[nouveau_nom] = users.pop(ancien_nom)
|
||||
save_users(users)
|
||||
return True
|
||||
return False
|
||||
|
||||
def mettre_a_jour_mot_de_passe(nom_utilisateur, nouveau_mdp):
|
||||
users = load_users()
|
||||
if nom_utilisateur in users:
|
||||
users[nom_utilisateur]["password_hash"] = hasher_mot_de_passe(nouveau_mdp)
|
||||
save_users(users)
|
||||
return True
|
||||
return False
|
||||
Reference in new issue
Block a user