From f802d99452250488170b9017a652ee826b66ae62 Mon Sep 17 00:00:00 2001 From: Rick Fryar Date: Mon, 24 Jul 2023 08:42:09 -0500 Subject: [PATCH] Add Clear link to clear cookies on expired token error message --- cps/templates/login.html | 1 + cps/web.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/cps/templates/login.html b/cps/templates/login.html index 94886528..a97c907c 100644 --- a/cps/templates/login.html +++ b/cps/templates/login.html @@ -50,6 +50,7 @@ {% endif %} {% endif %} +
{% if error %} diff --git a/cps/web.py b/cps/web.py index 789edd3d..0e856ec0 100755 --- a/cps/web.py +++ b/cps/web.py @@ -36,6 +36,7 @@ from sqlalchemy.exc import IntegrityError, InvalidRequestError, OperationalError from sqlalchemy.sql.expression import text, func, false, not_, and_, or_ from sqlalchemy.orm.attributes import flag_modified from sqlalchemy.sql.functions import coalesce +from urllib.parse import urlparse from werkzeug.datastructures import Headers from werkzeug.security import generate_password_hash, check_password_hash @@ -1414,6 +1415,14 @@ def logout(): log.debug("User logged out") return redirect(url_for('web.login')) +@web.route('/clear') +def clear(): + o = urlparse(request.base_url) + host = o.hostname + response = make_response(redirect('/login')) + response.set_cookie('session', '', expires=0, httponly=True, domain=host) + response.set_cookie('remember_token', '', expires=0, httponly=True,domain=host) + return response # ################################### Users own configuration ######################################################### def change_profile(kobo_support, local_oauth_check, oauth_status, translations, languages):