mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-15 15:28:50 -04:00
If user is logged in and visits / /sign-in or /register they will
be redirected to choose service.
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
from flask import render_template
|
||||
from flask import render_template, url_for, redirect
|
||||
from app.main import main
|
||||
from flask_login import login_required
|
||||
|
||||
from flask.ext.login import current_user
|
||||
|
||||
|
||||
@main.route('/')
|
||||
def index():
|
||||
if current_user and current_user.is_authenticated():
|
||||
return redirect(url_for('main.choose_service'))
|
||||
return render_template('views/signedout.html')
|
||||
|
||||
|
||||
|
||||
@@ -4,9 +4,12 @@ from flask import (
|
||||
render_template,
|
||||
redirect,
|
||||
session,
|
||||
abort
|
||||
abort,
|
||||
url_for
|
||||
)
|
||||
|
||||
from flask.ext.login import current_user
|
||||
|
||||
from client.errors import HTTPError
|
||||
|
||||
from app.main import main
|
||||
@@ -22,6 +25,9 @@ from app.notify_client.sender import send_sms_code, send_email_code
|
||||
|
||||
@main.route('/register', methods=['GET', 'POST'])
|
||||
def register():
|
||||
if current_user and current_user.is_authenticated():
|
||||
return redirect(url_for('main.choose_service'))
|
||||
|
||||
form = RegisterUserForm(users_dao.get_user_by_email)
|
||||
|
||||
if form.validate_on_submit():
|
||||
|
||||
@@ -2,11 +2,13 @@ from flask import (
|
||||
render_template,
|
||||
redirect,
|
||||
url_for,
|
||||
session,
|
||||
abort
|
||||
session
|
||||
)
|
||||
|
||||
|
||||
from flask.ext.login import current_user
|
||||
|
||||
|
||||
from app.main import main
|
||||
from app.main.dao import users_dao
|
||||
from app.main.forms import LoginForm
|
||||
@@ -15,6 +17,8 @@ from app.notify_client.sender import send_sms_code
|
||||
|
||||
@main.route('/sign-in', methods=(['GET', 'POST']))
|
||||
def sign_in():
|
||||
if current_user and current_user.is_authenticated():
|
||||
return redirect(url_for('main.choose_service'))
|
||||
try:
|
||||
form = LoginForm()
|
||||
if form.validate_on_submit():
|
||||
|
||||
Reference in New Issue
Block a user