Merge pull request #2132 from GSA/2109-build-out-architecture-for-new-about-pages-behind-feature-flag

Added new header button that is displayed in header
This commit is contained in:
Alex Janousek
2024-12-02 14:38:27 -05:00
committed by GitHub
3 changed files with 57 additions and 41 deletions

View File

@@ -1,7 +1,3 @@
import os
import secrets
from urllib.parse import unquote
from flask import (
abort,
current_app,
@@ -13,7 +9,7 @@ from flask import (
)
from flask_login import current_user
from app import redis_client, status_api_client
from app import status_api_client
from app.formatters import apply_html_class, convert_markdown_template
from app.main import main
from app.main.views.pricing import CURRENT_SMS_RATE
@@ -24,7 +20,6 @@ from app.main.views.sub_navigation_dictionaries import (
using_notify_nav,
)
from app.utils.user import user_is_logged_in
from notifications_utils.url_safe_token import generate_token
# Hook to check for feature flags
@@ -57,31 +52,10 @@ def index():
if current_user and current_user.is_authenticated:
return redirect(url_for("main.choose_account"))
ttl = 24 * 60 * 60
# make and store the state
state = generate_token(
str(request.remote_addr),
current_app.config["SECRET_KEY"],
current_app.config["DANGEROUS_SALT"],
)
state_key = f"login-state-{unquote(state)}"
redis_client.set(state_key, state, ex=ttl)
# make and store the nonce
nonce = secrets.token_urlsafe()
nonce_key = f"login-nonce-{unquote(nonce)}"
redis_client.set(nonce_key, nonce, ex=ttl)
url = os.getenv("LOGIN_DOT_GOV_INITIAL_SIGNIN_URL")
if url is not None:
url = url.replace("NONCE", nonce)
url = url.replace("STATE", state)
return render_template(
"views/signedout.html",
sms_rate=CURRENT_SMS_RATE,
counts=status_api_client.get_count_of_live_services_and_organizations(),
initial_signin_url=url,
counts=status_api_client.get_count_of_live_services_and_organizations()
)