1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-11-08 21:21:06 +00:00

Better password flash

This commit is contained in:
Mo 2022-06-28 17:01:42 +02:00
parent 40744c247e
commit 881c0cc895
3 changed files with 5 additions and 5 deletions

View file

@ -202,7 +202,7 @@ class UserView(SecureAdminModelView):
active_semester=form.active_semester.data, active_semester=form.active_semester.data,
) )
flashRandomPassword(password) flashRandomPassword(model.email, password)
return model return model
@ -220,7 +220,7 @@ class UserView(SecureAdminModelView):
if hasattr(form, "generate_new_password") and form.generate_new_password.data: if hasattr(form, "generate_new_password") and form.generate_new_password.data:
password = randomPassword() password = randomPassword()
flashRandomPassword(password) flashRandomPassword(model.email, password)
admin_change_password( admin_change_password(
model, password, notify=False model, password, notify=False

View file

@ -4,8 +4,8 @@ from flask import flash
from markupsafe import Markup from markupsafe import Markup
def flashRandomPassword(password): def flashRandomPassword(email: str, password: str):
flash(f"Random password: {password}", category="warning") flash(f"New random password for email {email}: {password}", category="warning")
def parse_bool(str): def parse_bool(str):

View file

@ -214,7 +214,7 @@ class AssistantUserView(SecureAssistantModelView):
def on_model_change(self, form, model, is_created): def on_model_change(self, form, model, is_created):
if form.generate_new_password.data: if form.generate_new_password.data:
password = randomPassword() password = randomPassword()
flashRandomPassword(password) flashRandomPassword(model.email, password)
admin_change_password(model, password, notify=False) # Password is automatically hashed with this function admin_change_password(model, password, notify=False) # Password is automatically hashed with this function