From 03353d49b151ea730c1396077c10dde48cc81a32 Mon Sep 17 00:00:00 2001 From: mrlan Date: Sun, 29 Jan 2023 10:57:58 +0800 Subject: [PATCH] Bug525-Hui (#79) Co-authored-by: Hui Lan Reviewed-on: http://121.4.94.30:3000/mrlan/EnglishPal/pulls/79 Co-authored-by: mrlan Co-committed-by: mrlan --- app/Login.py | 4 ++-- app/templates/expiry.html | 2 +- app/user_service.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Login.py b/app/Login.py index 1ada0af..8e0030b 100644 --- a/app/Login.py +++ b/app/Login.py @@ -1,6 +1,6 @@ import hashlib import string -from datetime import datetime +from datetime import datetime, timedelta from UseSqlite import InsertQuery, RecordQuery path_prefix = '/var/www/wordfreq/wordfreq/' @@ -23,7 +23,7 @@ def verify_user(username, password): def add_user(username, password): start_date = datetime.now().strftime('%Y%m%d') - expiry_date = '20221230' + expiry_date = (datetime.now() + timedelta(days=30)).strftime('%Y%m%d') # will expire after 30 days # 将用户名和密码一起加密,以免暴露不同用户的相同密码 password = md5(username + password) rq = InsertQuery(path_prefix + 'static/wordfreqapp.db') diff --git a/app/templates/expiry.html b/app/templates/expiry.html index 797a109..9464325 100644 --- a/app/templates/expiry.html +++ b/app/templates/expiry.html @@ -5,7 +5,7 @@ 账号过期 -

您的账号{{ username }}过期。

+

您的账号过期(过期日 {{expiry_date}})。

为了提高服务质量,English Pal 收取会员费用, 每天1元。

请决定你要试用的时间长度,扫描下面支付宝二维码支付。 支付时请注明English Pal Membership Fee。 我们会于12小时内激活账号。

支付宝二维码

diff --git a/app/user_service.py b/app/user_service.py index 79c7888..2d10404 100644 --- a/app/user_service.py +++ b/app/user_service.py @@ -107,7 +107,7 @@ def userpage(username): # 用户过期 user_expiry_date = session.get('expiry_date') if datetime.now().strftime('%Y%m%d') > user_expiry_date: - return render_template('expiry.html') + return render_template('expiry.html', expiry_date=user_expiry_date) # 获取session里的用户名 username = session.get('username')