This commit is contained in:
Aaron Lee 2021-10-01 15:08:10 +00:00
parent e5f79463ae
commit 9aefbb7d20

6
app.py
View file

@ -52,11 +52,13 @@ def index():
return render_template('login.html')
return redirect('/manage')
elif request.method == 'POST':
email = request.form['username'] + "@group-attendance.fhjh.tp.edu.tw"
if check_login_status():
try:
if (verify_recaptcha(request.form['g-recaptcha-response'])):
user = auth.sign_in_with_email_and_password(
request.form['username'] + "@group-attendance.fhjh.tp.edu.tw", request.form['password'])
email, request.form['password'])
print("Login SUCC:", email, flush=True)
session['is_logged_in'] = True
session['email'] = user['email']
session['uid'] = user['localId']
@ -65,10 +67,12 @@ def index():
session['loginTime'] = datetime.now(tz)
return redirect('/manage')
else:
print("ReC Error:", email, flush=True)
flash(
'reCAPTCHA 錯誤,請稍後再試一次<br>reCAPTCHA Failed. Please try again later.')
return redirect('/')
except Exception as e:
print("Error:", email, str(e), flush=True)
flash(
'帳號或密碼錯誤,請重新輸入<br>Incorrect username or password')
return redirect('/')