From b5625ecf1f996c49f436622f4cc512f0f06e05e2 Mon Sep 17 00:00:00 2001 From: zhengxinonly Date: Fri, 22 Dec 2023 23:01:45 +0800 Subject: [PATCH] =?UTF-8?q?refactor(templates):=20=E7=A7=BB=E9=99=A4=20jin?= =?UTF-8?q?ja2=20includes=20=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pear_admin/extensions/init_jwt.py | 2 +- static/js/pear_admin_flask.js | 10 ++++++++++ templates/includes/script.html | 20 -------------------- templates/index.html | 10 +++++++++- templates/login.html | 14 -------------- 5 files changed, 20 insertions(+), 36 deletions(-) create mode 100644 static/js/pear_admin_flask.js delete mode 100644 templates/includes/script.html diff --git a/pear_admin/extensions/init_jwt.py b/pear_admin/extensions/init_jwt.py index 7b1a881..3d077b6 100644 --- a/pear_admin/extensions/init_jwt.py +++ b/pear_admin/extensions/init_jwt.py @@ -14,7 +14,7 @@ def user_identity_lookup(user): @jwt.user_lookup_loader def user_lookup_callback(_jwt_header, jwt_data): identity = jwt_data["sub"] - return UserORM.query.filter_by(id=identity).one_or_none() + return UserORM.query.filter(UserORM.id == identity).one_or_none() @jwt.expired_token_loader diff --git a/static/js/pear_admin_flask.js b/static/js/pear_admin_flask.js new file mode 100644 index 0000000..95f4a83 --- /dev/null +++ b/static/js/pear_admin_flask.js @@ -0,0 +1,10 @@ +function getCookie(name) { + let matches = document.cookie.match( + new RegExp( + "(?:^|; )" + + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, "\\$1") + + "=([^;]*)", + ), + ); + return matches ? decodeURIComponent(matches[1]) : undefined; +} diff --git a/templates/includes/script.html b/templates/includes/script.html deleted file mode 100644 index 1da6642..0000000 --- a/templates/includes/script.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - diff --git a/templates/index.html b/templates/index.html index 2afa7fc..363d56f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -7,7 +7,15 @@ content="width=device-width, initial-scale=1, maximum-scale=1" /> Pear Admin Flask - {% include 'includes/script.html' %} + + + + + + + + + diff --git a/templates/login.html b/templates/login.html index 4d2c5c9..a86d1fa 100644 --- a/templates/login.html +++ b/templates/login.html @@ -70,20 +70,6 @@ /> -