mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-29 10:30:20 -04:00
Move redirect_to_signin helper to new util module
We'll expand this module in later commits.
This commit is contained in:
@@ -4,7 +4,7 @@ from app import user_api_client
|
||||
from app.main import main
|
||||
from app.main.forms import TextNotReceivedForm
|
||||
from app.models.user import User
|
||||
from app.utils import redirect_to_sign_in
|
||||
from app.utils.login import redirect_to_sign_in
|
||||
|
||||
|
||||
@main.route('/resend-email-verification')
|
||||
|
||||
@@ -16,7 +16,8 @@ from app import user_api_client
|
||||
from app.main import main
|
||||
from app.main.forms import TwoFactorForm
|
||||
from app.models.user import User
|
||||
from app.utils import is_less_than_days_ago, redirect_to_sign_in
|
||||
from app.utils import is_less_than_days_ago
|
||||
from app.utils.login import redirect_to_sign_in
|
||||
|
||||
|
||||
@main.route('/two-factor-email-sent', methods=['GET'])
|
||||
|
||||
@@ -17,7 +17,7 @@ from app.main import main
|
||||
from app.main.forms import TwoFactorForm
|
||||
from app.models.service import Service
|
||||
from app.models.user import InvitedOrgUser, InvitedUser, User
|
||||
from app.utils import redirect_to_sign_in
|
||||
from app.utils.login import redirect_to_sign_in
|
||||
|
||||
|
||||
@main.route('/verify', methods=['GET', 'POST'])
|
||||
|
||||
@@ -10,7 +10,8 @@ from app.main.views.two_factor import log_in_user
|
||||
from app.models.user import User
|
||||
from app.models.webauthn_credential import RegistrationError, WebAuthnCredential
|
||||
from app.notify_client.user_api_client import user_api_client
|
||||
from app.utils import is_less_than_days_ago, redirect_to_sign_in
|
||||
from app.utils import is_less_than_days_ago
|
||||
from app.utils.login import redirect_to_sign_in
|
||||
from app.utils.user import user_is_platform_admin
|
||||
|
||||
|
||||
|
||||
@@ -5,16 +5,7 @@ from urllib.parse import urlparse
|
||||
|
||||
import pytz
|
||||
from dateutil import parser
|
||||
from flask import (
|
||||
abort,
|
||||
current_app,
|
||||
g,
|
||||
make_response,
|
||||
redirect,
|
||||
request,
|
||||
session,
|
||||
url_for,
|
||||
)
|
||||
from flask import abort, current_app, g, make_response, request
|
||||
from flask_login import current_user
|
||||
from notifications_utils.field import Field
|
||||
from notifications_utils.timezones import utc_string_to_aware_gmt_datetime
|
||||
@@ -45,16 +36,6 @@ def service_has_permission(permission):
|
||||
return wrap
|
||||
|
||||
|
||||
def redirect_to_sign_in(f):
|
||||
@wraps(f)
|
||||
def wrapped(*args, **kwargs):
|
||||
if 'user_details' not in session:
|
||||
return redirect(url_for('main.sign_in'))
|
||||
else:
|
||||
return f(*args, **kwargs)
|
||||
return wrapped
|
||||
|
||||
|
||||
def get_help_argument():
|
||||
return request.args.get('help') if request.args.get('help') in ('1', '2', '3') else None
|
||||
|
||||
|
||||
13
app/utils/login.py
Normal file
13
app/utils/login.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from functools import wraps
|
||||
|
||||
from flask import redirect, session, url_for
|
||||
|
||||
|
||||
def redirect_to_sign_in(f):
|
||||
@wraps(f)
|
||||
def wrapped(*args, **kwargs):
|
||||
if 'user_details' not in session:
|
||||
return redirect(url_for('main.sign_in'))
|
||||
else:
|
||||
return f(*args, **kwargs)
|
||||
return wrapped
|
||||
Reference in New Issue
Block a user