From 4a13d3ceb140797faa3d6b0b6adb5c2fdffe8931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sat, 23 Jan 2021 09:31:31 +0100 Subject: [PATCH] fixed issue that on register_user the birthday can be set --- flaschengeist/controller/userController.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/flaschengeist/controller/userController.py b/flaschengeist/controller/userController.py index 8c13782..283de3d 100644 --- a/flaschengeist/controller/userController.py +++ b/flaschengeist/controller/userController.py @@ -7,6 +7,7 @@ from flaschengeist import logger from flaschengeist.config import config from flaschengeist.database import db from flaschengeist.utils.hook import Hook +from flaschengeist.utils.datetime import from_iso_format from flaschengeist.models.user import User, Role, _PasswordReset from flaschengeist.controller import messageController, sessionController @@ -46,7 +47,9 @@ def request_reset(user: User): logger.debug(f"New password reset request for {user.userid}") reset = _generate_password_reset(user) - subject = str(config["MESSAGES"]["password_subject"]).format(name=user.display_name, username=user.userid) + subject = str(config["MESSAGES"]["password_subject"]).format( + name=user.display_name, username=user.userid + ) text = str(config["MESSAGES"]["password_text"]).format( name=user.display_name, username=user.userid, @@ -155,7 +158,9 @@ def find_user(uid_mail): if user: update_user(user) else: - user = current_app.config["FG_AUTH_BACKEND"].find_user(uid_mail, uid_mail if mail else None) + user = current_app.config["FG_AUTH_BACKEND"].find_user( + uid_mail, uid_mail if mail else None + ) if user: db.session.add(user) db.session.commit() @@ -173,6 +178,8 @@ def register(data): allowed_keys = User().serialize().keys() values = {key: value for key, value in data.items() if key in allowed_keys} roles = values.pop("roles", []) + if "birthday" in values: + values["birthday"] = from_iso_format(values["birthday"]).date() user = User(**values) set_roles(user, roles) @@ -183,7 +190,9 @@ def register(data): reset = _generate_password_reset(user) - subject = str(config["MESSAGES"]["welcome_subject"]).format(name=user.display_name, username=user.userid) + subject = str(config["MESSAGES"]["welcome_subject"]).format( + name=user.display_name, username=user.userid + ) text = str(config["MESSAGES"]["welcome_text"]).format( name=user.display_name, username=user.userid,