mirror of
https://github.com/aaronleetw/Attendance.git
synced 2024-11-14 19:11:39 -08:00
Made SQL and timezones work
This commit is contained in:
parent
22ef472527
commit
2adbd4b4dc
3 changed files with 5 additions and 5 deletions
2
app.py
2
app.py
|
@ -145,4 +145,4 @@ admin.add_link(MenuLink(name='Back to Home 返回一般管理', category='', url
|
|||
admin.add_link(MenuLink(name='Logout 登出', category='', url='/logout'))
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True, host='0.0.0.0', port=80)
|
||||
app.run(debug=True, host='0.0.0.0', port=5000)
|
||||
|
|
1
db.sql
1
db.sql
|
@ -76,7 +76,6 @@ CREATE TABLE homerooms (
|
|||
*/
|
||||
);
|
||||
|
||||
DELETE FROM submission WHERE grade=9;
|
||||
CREATE TABLE submission (
|
||||
id INT NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (id),
|
||||
|
|
5
login.py
5
login.py
|
@ -190,7 +190,7 @@ def chgPassword():
|
|||
<hr>
|
||||
<small>This email was sent automatically. Please do not reply.<br>
|
||||
這個郵件是自動發送的,請不要回覆。</small>
|
||||
""" % (str(datetime.now(tz)), request.form['new_username'], str(datetime.now(tz)), request.form['new_username']))
|
||||
""" % (datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S"), request.form['new_username'], datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S"), request.form['new_username']))
|
||||
flash(
|
||||
'修改密碼成功,請重新登入<br>Password changed successfully. Please login again.')
|
||||
return redirect('/')
|
||||
|
@ -284,9 +284,10 @@ def resetPassword():
|
|||
""", (request.args.get('resetCode'),))
|
||||
user = cursor.fetchone()
|
||||
cursor.close()
|
||||
dtnow = datetime.now(tz).replace(tzinfo=None)
|
||||
if user == None:
|
||||
raise Exception('無此重置密碼代碼<br>Invalid reset password code')
|
||||
if (datetime.now(tz) - datetime.strptime(user[2], '%Y-%m-%d %H:%M:%S')).seconds > 3600:
|
||||
if (dtnow - datetime.strptime(user[2], '%Y-%m-%d %H:%M:%S')).seconds > 3600:
|
||||
cursor.execute("DELETE FROM forgot WHERE resetID = %s", (user[0],))
|
||||
db.commit()
|
||||
cursor.close()
|
||||
|
|
Loading…
Reference in a new issue