From 86ac810fff18226c0f163dd3a38a946dfd998ff4 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Wed, 18 Oct 2023 15:18:37 -0700 Subject: [PATCH] initial for login.gov integration --- app/main/forms.py | 1 + app/main/views/sign_in.py | 9 +++++++++ app/templates/views/signin.html | 6 +++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index 0be785a5e..df8f13c4c 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -4,6 +4,7 @@ from itertools import chain from numbers import Number import pytz +import requests from flask import Markup, render_template, request from flask_login import current_user from flask_wtf import FlaskForm as Form diff --git a/app/main/views/sign_in.py b/app/main/views/sign_in.py index 6420ad23b..a1cf8fc32 100644 --- a/app/main/views/sign_in.py +++ b/app/main/views/sign_in.py @@ -24,6 +24,15 @@ from app.utils.login import is_safe_redirect_url @main.route("/sign-in", methods=(["GET", "POST"])) @hide_from_search_engines def sign_in(): + code = request.args.get("code") + state = request.args.get("state") + if code and state: + print(f"HURRAY! THIS IS REDIRECT FROM LOGIN DOT GOV AND WE HAVE CODE {code} and STATE {state}") + # TODO use the code to get the access_token with jwt + # Using the access_token get the email from the user info + # Use the call five lines down to look up the user from the email + # activate the user and redirect as five lines down + redirect_url = request.args.get("next") if os.getenv("NOTIFY_E2E_TEST_EMAIL"): diff --git a/app/templates/views/signin.html b/app/templates/views/signin.html index 33bbcf29a..03ed1ea6b 100644 --- a/app/templates/views/signin.html +++ b/app/templates/views/signin.html @@ -29,10 +29,10 @@ {% else %}