diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2021-06-05 17:45:41 +0530 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2021-06-05 17:45:41 +0530 |
commit | f8b29478f5481b39225d77b630049f759a572ce7 (patch) | |
tree | b48371e1474406aae821a16204f2d2eca2c7b390 /app/views/auth.py | |
parent | e5f50733e63c2f5bef34e966aaa4c881d71a1688 (diff) |
added redirects if already logged in
Diffstat (limited to 'app/views/auth.py')
-rw-r--r-- | app/views/auth.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/views/auth.py b/app/views/auth.py index 983380e..487ae9b 100644 --- a/app/views/auth.py +++ b/app/views/auth.py @@ -1,12 +1,14 @@ from app import app, db, models, login_manager, oauth from app.forms.app_forms import UserSignUp, UserLogIn -from flask import render_template, flash,url_for, redirect +from flask import render_template, flash,url_for, redirect, request from app.misc_func import flash_errors import flask_login from sqlalchemy.exc import IntegrityError @app.route("/signup", methods=['GET', 'POST']) def register_user(): + if request.method == "GET" and flask_login.current_user.is_authenticated: + return redirect(url_for("user_dashboard")) form = UserSignUp() if form.validate_on_submit(): user = models.User( @@ -29,6 +31,8 @@ def register_user(): @app.route("/signin", methods=['GET', 'POST']) def signin_user(): + if request.method == "GET" and flask_login.current_user.is_authenticated: + return redirect(url_for("user_dashboard")) form = UserLogIn() if form.validate_on_submit(): user = models.User.query.filter_by(email=form.email.data).first() |