1
0
forked from ScoDoc/ScoDoc

Fix #269. Utilisateurs avec logins numériques.

This commit is contained in:
Emmanuel Viennet 2022-01-13 23:30:25 +01:00
parent b6cedbd6b6
commit fa99cbf3d0

View File

@ -151,6 +151,8 @@ def user_info(user_name, format="json"):
@scodoc7func @scodoc7func
def create_user_form(user_name=None, edit=0, all_roles=1): def create_user_form(user_name=None, edit=0, all_roles=1):
"form. création ou edition utilisateur" "form. création ou edition utilisateur"
if user_name is not None: # scodoc7func converti en int !
user_name = str(user_name)
auth_dept = current_user.dept auth_dept = current_user.dept
from_mail = current_user.email from_mail = current_user.email
initvalues = {} initvalues = {}
@ -745,6 +747,8 @@ def user_info_page(user_name=None):
""" """
from app.scodoc.sco_permissions_check import can_handle_passwd from app.scodoc.sco_permissions_check import can_handle_passwd
if user_name is not None: # scodoc7func converti en int !
user_name = str(user_name)
# peut on divulguer ces infos ? # peut on divulguer ces infos ?
if not can_handle_passwd(current_user, allow_admindepts=True): if not can_handle_passwd(current_user, allow_admindepts=True):
raise AccessDenied("Vous n'avez pas la permission de voir cette page") raise AccessDenied("Vous n'avez pas la permission de voir cette page")
@ -753,7 +757,7 @@ def user_info_page(user_name=None):
if not user_name: if not user_name:
user = current_user user = current_user
else: else:
user = User.query.filter_by(user_name=str(user_name)).first() user = User.query.filter_by(user_name=user_name).first()
if not user: if not user:
raise ScoValueError("invalid user_name") raise ScoValueError("invalid user_name")
@ -802,6 +806,8 @@ def form_change_password(user_name=None):
"""Formulaire de changement mot de passe de l'utilisateur user_name. """Formulaire de changement mot de passe de l'utilisateur user_name.
Un utilisateur peut toujours changer son propre mot de passe. Un utilisateur peut toujours changer son propre mot de passe.
""" """
if user_name is not None: # scodoc7func converti en int !
user_name = str(user_name)
if not user_name: if not user_name:
user = current_user user = current_user
else: else:
@ -850,6 +856,8 @@ def form_change_password(user_name=None):
@scodoc7func @scodoc7func
def change_password(user_name, password, password2): def change_password(user_name, password, password2):
"Change the password for user given by user_name" "Change the password for user given by user_name"
if user_name is not None: # scodoc7func converti en int !
user_name = str(user_name)
u = User.query.filter_by(user_name=user_name).first() u = User.query.filter_by(user_name=user_name).first()
# Check access permission # Check access permission
if not can_handle_passwd(u): if not can_handle_passwd(u):
@ -909,6 +917,8 @@ def change_password(user_name, password, password2):
@permission_required(Permission.ScoUsersAdmin) @permission_required(Permission.ScoUsersAdmin)
def toggle_active_user(user_name: str = None): def toggle_active_user(user_name: str = None):
"""Change active status of a user account""" """Change active status of a user account"""
if user_name is not None: # scodoc7func converti en int !
user_name = str(user_name)
u = User.query.filter_by(user_name=user_name).first() u = User.query.filter_by(user_name=user_name).first()
if not u: if not u:
raise ScoValueError("invalid user_name") raise ScoValueError("invalid user_name")