From 2f833dc457dcf3b021ad6340b87039bd35e4e92f Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sat, 20 Jun 2020 13:46:12 +0200 Subject: [PATCH] Fix login with remember me token --- cps/static/js/table.js | 2 +- cps/templates/book_table.html | 23 ++++++++++++++++++++++- cps/templates/layout.html | 6 ++++-- cps/web.py | 4 +++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/cps/static/js/table.js b/cps/static/js/table.js index 75d70d8d..8d5633e2 100644 --- a/cps/static/js/table.js +++ b/cps/static/js/table.js @@ -55,7 +55,7 @@ $(function() { $("#books-table").bootstrapTable('uncheckAll'); }); - $("#merge_books").click(function() { + $("#merge_confirm").click(function() { $.ajax({ method:"post", contentType: "application/json; charset=utf-8", diff --git a/cps/templates/book_table.html b/cps/templates/book_table.html index 3c3f964b..4c86504f 100644 --- a/cps/templates/book_table.html +++ b/cps/templates/book_table.html @@ -20,7 +20,7 @@

{{_(title)}}

-
{{_('Merge selected books')}}
+
{{_('Merge selected books')}}
{{_('Remove Selections')}}
@@ -62,6 +62,27 @@ {% endblock %} {% block modal %} {{ delete_book(0) }} +{% if g.user.role_edit() %} + +{% endif %} + {% endblock %} {% block js %} diff --git a/cps/templates/layout.html b/cps/templates/layout.html index 8252bf4c..a1dbe976 100644 --- a/cps/templates/layout.html +++ b/cps/templates/layout.html @@ -222,9 +222,11 @@ }); $(document).ready(function() { var inp = $('#query').first() - var val = inp.val() - if (val.length) { + if (inp.length) { + var val = inp.val() + if (val.length) { inp.val('').blur().focus().val(val) + } } }); }); diff --git a/cps/web.py b/cps/web.py index 579403fc..8d48bee7 100644 --- a/cps/web.py +++ b/cps/web.py @@ -36,7 +36,7 @@ from babel.core import UnknownLocaleError from flask import Blueprint from flask import render_template, request, redirect, send_from_directory, make_response, g, flash, abort, url_for from flask_babel import gettext as _ -from flask_login import login_user, logout_user, login_required, current_user +from flask_login import login_user, logout_user, login_required, current_user, confirm_login from sqlalchemy.exc import IntegrityError, InvalidRequestError, OperationalError from sqlalchemy.sql.expression import text, func, true, false, not_, and_, or_ from werkzeug.exceptions import default_exceptions, InternalServerError @@ -294,6 +294,8 @@ def render_title_template(*args, **kwargs): @web.before_app_request def before_request(): + if current_user.is_authenticated: + confirm_login() g.user = current_user g.allow_registration = config.config_public_reg g.allow_anonymous = config.config_anonbrowse