From 801358b905653d67c5a86ab13c7ec31ea6b52ea7 Mon Sep 17 00:00:00 2001 From: Kiran Jonnalagadda Date: Fri, 27 Oct 2023 23:15:12 +0530 Subject: [PATCH] Autoset shouldn't accept a user parameter --- funnel/views/account.py | 2 +- funnel/views/helpers.py | 6 ++++-- funnel/views/login_session.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/funnel/views/account.py b/funnel/views/account.py index 4a5776e24..a28a7f8bc 100644 --- a/funnel/views/account.py +++ b/funnel/views/account.py @@ -348,7 +348,7 @@ def edit(self) -> ReturnView: form = AccountForm(obj=current_auth.user) if form.validate_on_submit(): form.populate_obj(current_auth.user) - autoset_timezone_and_locale(current_auth.user) + autoset_timezone_and_locale() db.session.commit() user_data_changed.send(current_auth.user, changes=['profile']) diff --git a/funnel/views/helpers.py b/funnel/views/helpers.py index cc34749af..c87755592 100644 --- a/funnel/views/helpers.py +++ b/funnel/views/helpers.py @@ -35,6 +35,7 @@ from werkzeug.routing import BuildError, RequestRedirect from baseframe import cache, statsd +from coaster.auth import current_auth from coaster.sqlalchemy import RoleMixin from coaster.utils import utcnow @@ -250,8 +251,9 @@ def get_scheme_netloc(uri: str) -> tuple[str, str]: return (parsed_uri.scheme, parsed_uri.netloc) -def autoset_timezone_and_locale(user: Account) -> None: - # Set the user's timezone and locale automatically if required +def autoset_timezone_and_locale() -> None: + """Set the current user's timezone and locale automatically if required.""" + user = current_auth.user if ( user.auto_timezone or not user.timezone diff --git a/funnel/views/login_session.py b/funnel/views/login_session.py index 075712dd3..7ab5f3086 100644 --- a/funnel/views/login_session.py +++ b/funnel/views/login_session.py @@ -842,7 +842,7 @@ def login_internal( current_auth.cookie['sessionid'] = login_session.buid current_auth.cookie['userid'] = user.buid session.permanent = True - autoset_timezone_and_locale(user) + autoset_timezone_and_locale() user_login.send(user)