From f8b29478f5481b39225d77b630049f759a572ce7 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Sat, 5 Jun 2021 17:45:41 +0530 Subject: added redirects if already logged in --- app/views/auth.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/views') 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() -- cgit v1.2.3