debug and etc

This commit is contained in:
Kenneth Kehl
2023-11-10 11:08:52 -08:00
parent 853af1040e
commit 6f9e55cba0
4 changed files with 645 additions and 1 deletions

View File

@@ -25,6 +25,8 @@ from app.models.user import InvitedUser, User
from app.utils import hide_from_search_engines
from app.utils.login import is_safe_redirect_url
# This is the logout url for manual use until we figure out how to do programmatically
# https://idp.int.identitysandbox.gov/openid_connect/logout?client_id=urn:gov:gsa:openidconnect.profiles:sp:sso:gsa:test_notify_gov&post_logout_redirect_uri=http://localhost:6012/sign-in
def _get_access_token(code, state):
client_id = os.getenv("LOGIN_DOT_GOV_CLIENT_ID")
@@ -73,6 +75,7 @@ def sign_in():
state = request.args.get("state")
login_gov_error = request.args.get("error")
if code and state:
current_app.logger.info(f"found login.gov code and state {code} {state}")
access_token = _get_access_token(code, state)
user_email = _get_user_email(access_token)
redirect_url = request.args.get("next")
@@ -94,12 +97,14 @@ def sign_in():
activate_user(user["id"])
return redirect(url_for("main.show_accounts_or_dashboard", next=redirect_url))
current_app.logger.info(f"current user is {current_user}")
if current_user and current_user.is_authenticated:
if redirect_url and is_safe_redirect_url(redirect_url):
return redirect(redirect_url)
return redirect(url_for("main.show_accounts_or_dashboard"))
form = LoginForm()
current_app.logger.info("Got the login form")
password_reset_url = url_for(".forgot_password", next=request.args.get("next"))
if form.validate_on_submit():
@@ -148,6 +153,7 @@ def sign_in():
other_device = current_user.logged_in_elsewhere()
notify_env = os.getenv("NOTIFY_ENVIRONMENT")
current_app.logger.info("should render the sign in template")
return render_template(
"views/signin.html",
form=form,

View File

@@ -39,6 +39,7 @@ class UserApiClient(NotifyAdminAPIClient):
return self.get("/user/{}".format(user_id))
def get_user_by_email(self, email_address):
current_app.logger.info(f"Going to get user by email {email_address}")
user_data = self.post("/user/email", data={"email": email_address})
return user_data["data"]