From 881c0cc8953fd7c8f7f99fc8460de0d50b8dedf3 Mon Sep 17 00:00:00 2001 From: Mo8it Date: Tue, 28 Jun 2022 17:01:42 +0200 Subject: [PATCH] Better password flash --- advlabdb/adminModelViews.py | 4 ++-- advlabdb/advlabdb_independent_funs.py | 4 ++-- advlabdb/assistantModelViews.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/advlabdb/adminModelViews.py b/advlabdb/adminModelViews.py index c7367f4..f9cbe85 100644 --- a/advlabdb/adminModelViews.py +++ b/advlabdb/adminModelViews.py @@ -202,7 +202,7 @@ class UserView(SecureAdminModelView): active_semester=form.active_semester.data, ) - flashRandomPassword(password) + flashRandomPassword(model.email, password) return model @@ -220,7 +220,7 @@ class UserView(SecureAdminModelView): if hasattr(form, "generate_new_password") and form.generate_new_password.data: password = randomPassword() - flashRandomPassword(password) + flashRandomPassword(model.email, password) admin_change_password( model, password, notify=False diff --git a/advlabdb/advlabdb_independent_funs.py b/advlabdb/advlabdb_independent_funs.py index f7c6c94..30b05b4 100644 --- a/advlabdb/advlabdb_independent_funs.py +++ b/advlabdb/advlabdb_independent_funs.py @@ -4,8 +4,8 @@ from flask import flash from markupsafe import Markup -def flashRandomPassword(password): - flash(f"Random password: {password}", category="warning") +def flashRandomPassword(email: str, password: str): + flash(f"New random password for email {email}: {password}", category="warning") def parse_bool(str): diff --git a/advlabdb/assistantModelViews.py b/advlabdb/assistantModelViews.py index 582d783..00c9fe7 100644 --- a/advlabdb/assistantModelViews.py +++ b/advlabdb/assistantModelViews.py @@ -214,7 +214,7 @@ class AssistantUserView(SecureAssistantModelView): def on_model_change(self, form, model, is_created): if form.generate_new_password.data: password = randomPassword() - flashRandomPassword(password) + flashRandomPassword(model.email, password) admin_change_password(model, password, notify=False) # Password is automatically hashed with this function