From 4808509139462c03308d1e2d003bde6977e49af4 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Wed, 11 Mar 2020 12:12:15 +0000 Subject: [PATCH] make flask_login upgrade backwards compatible flask_login moves from `user_id` to `_user_id`. unfortunately, this isn't backwards compatible as if an old cookie only has the old `user_id`, then flask_login won't find `_user_id` so will mark the user as unauthenticated. this code will manually migrate the three flask login cookie variables, before the flask_login code runs, so that it doesn't freak out --- app/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/__init__.py b/app/__init__.py index 625a697b0..43d9e2019 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -527,6 +527,12 @@ def make_session_permanent(): when you first log in/sign up/get invited/etc, but we do it just to be safe. For more reading, check here: https://stackoverflow.com/questions/34118093/flask-permanent-session-where-to-define-them """ + + # TODO: Remove this loop after a weekend, when all cookies have either run through this code or expired + for val in ['user_id', 'remember', 'remember_seconds']: + if val in session: + session[f'_{val}'] = session[val] + session.permanent = True