From 00a3b645ff7b2d867188313e362be4804d01e545 Mon Sep 17 00:00:00 2001 From: bug_creator Date: Wed, 1 Dec 2021 17:32:21 +0800 Subject: [PATCH] fix bug|test register --- app/auth/views.py | 16 +- app/templates/auth/login-and-register.html | 180 ++++++++++++++++++++- data-dev.sqlite | Bin 6885376 -> 6885376 bytes 3 files changed, 183 insertions(+), 13 deletions(-) diff --git a/app/auth/views.py b/app/auth/views.py index 0b687e7..730c646 100644 --- a/app/auth/views.py +++ b/app/auth/views.py @@ -35,17 +35,17 @@ def login(): user = User.query.filter_by(student_id=student_id).first() if user is None: flash("Your StudentID/OrganizationID has not been registered") - return render_template('auth/login.html') + return redirect(url_for('auth.login')) elif user.verify_password(password) is False: flash("StudentID/OrganizationID or password error") - return render_template('auth/login.html') + return redirect(url_for('auth.login')) if user is not None and user.verify_password(password): login_user(user, True) next = request.args.get('next') if next is None or not next.startswith('/'): next = url_for('main.index') return redirect(next) - return render_template('auth/login.html') + return redirect(url_for('auth.login')) # # 登录 @@ -112,23 +112,23 @@ def register(): is_student = Students.query.filter_by(student_id=request.form["BJUT_id"]).first() # 学号 if is_student is None: flash("Sorry, you are not a BJUT student and cannot sign up for this account.") - return render_template('auth/register.html') + return redirect(url_for('auth.login')) if is_student.id_number != request.form["id_num"]: flash("Your student ID does not match your ID number, you cannot register for this account.") - return render_template('auth/register.html') + return redirect(url_for('auth.login')) if is_student is not None and is_student.id_number == request.form["id_num"]: if is_student.confirmed: flash("Your student number has been registered, you cannot register for a second SOFB account") - return render_template('auth/register.html') + return redirect(url_for('auth.login')) else: email_find = User.query.filter_by(email=request.form["email"]).first() if email_find is not None: flash("Your email has been registered, please change your email") - return render_template('auth/register.html') + return redirect(url_for('auth.login')) username_find = User.query.filter_by(username=request.form["user_name"]).first() if username_find is not None: flash("Your username has been registered, please change your username") - return render_template('auth/register.html') + return redirect(url_for('auth.login')) student = Students.query.filter_by(student_id=request.form["BJUT_id"]).first() user = User(email=request.form["email"], ID_number=request.form["id_num"], diff --git a/app/templates/auth/login-and-register.html b/app/templates/auth/login-and-register.html index d9e113d..6613ca9 100644 --- a/app/templates/auth/login-and-register.html +++ b/app/templates/auth/login-and-register.html @@ -25,9 +25,20 @@ {% block body %}
+ {% with messages =get_flashed_messages() %} + {% if messages %} + + {% else %} +
+ {% endif %} + {% endwith %}
diff --git a/data-dev.sqlite b/data-dev.sqlite index 87502db27ad9658499260c548e71206aa8b37da0..fb1763eebf65cbf73618a47b178c8eacdf9da9eb 100644 GIT binary patch delta 1106 zcmZ|NUuYCZ90%~7-Q;dJ?)|aG#A<9}o2JH^yP3J&+1=CHoPTTeQnhOQ@9o}Z)TF=(lLEPN&c3&V0JYOi4TRNnOE zRW*x>Uo>$(_%4(@KYZHfw#aiqF*<3bpPd=xyZfy2<^EHHXFDmCjvG3%?1v7weMo$x7i!Dp}*x?vrB4(p)@GLQud3^?S# z0=qstCw8jZd9}9|pBGP6wHLQML~5n`BAtHwJ6|8K+!@0xIN*W@dDs9O;S1OVUqUYw zU^8rit*{NY!w&cgcEZ=N3wA>h`rsSb1AAc~d<*;G033vVI0T2`2polDa2!s+NhpC2 S0hA$x0g!O2Ub=sJviK4`Zjo64 delta 673 zcmW;GJ4{mn6vpxUXu00@K5Eq#p$hn@_$mdpA}SP75w%#~Z!Od-G_fgzI+z$r9J-hk z(lkw+7%;}o<_0=6jZHTb2NR;Piwtfi?u`C%_$}w0@0^oeT#~bxZx@RTff2D-PQ0BJ z1^e%;ztdrg%7sOYmqTY z&Pa)pQje^0=apEBHX@$fOe2Eh=*I~R;3Q7rGzKw*D28zcBRGq5IFC_Wz!)y#5-uZ# vaa=(hS8)y3aRWDT3%79xcX1E*@c<9;2#=A#1SXNh6IghPsme@adOr3KEAT9z