diff --git a/app/main/views/sign_in.py b/app/main/views/sign_in.py index 402e61a08..6de46b023 100644 --- a/app/main/views/sign_in.py +++ b/app/main/views/sign_in.py @@ -63,6 +63,10 @@ def _get_access_token(code, state): url = f"{base_url}{cli_assert}&{cli_assert_type}&{code_param}&grant_type=authorization_code" headers = {"Authorization": "Bearer %s" % token} response = requests.post(url, headers=headers) + if response.json().get("access_token") is None: + # Capture the response json here so it hopefully shows up in error reports + current_app.logger.error(f"Error when getting access token {response.json()}") + raise KeyError(f"'access_token' {response.json()}") access_token = response.json()["access_token"] return access_token @@ -84,13 +88,17 @@ def _do_login_dot_gov(): code = request.args.get("code") state = request.args.get("state") login_gov_error = request.args.get("error") - if code and state: - access_token = _get_access_token(code, state) - user_email, user_uuid = _get_user_email_and_uuid(access_token) - redirect_url = request.args.get("next") + + if login_gov_error: + current_app.logger.error(f"login.gov error: {login_gov_error}") + raise Exception(f"Could not login with login.gov {login_gov_error}") + elif code and state: # activate the user try: + access_token = _get_access_token(code, state) + user_email, user_uuid = _get_user_email_and_uuid(access_token) + redirect_url = request.args.get("next") user = user_api_client.get_user_by_uuid_or_email(user_uuid, user_email) activate_user(user["id"]) except BaseException as be: # noqa B036 @@ -99,9 +107,6 @@ def _do_login_dot_gov(): return redirect(url_for("main.show_accounts_or_dashboard", next=redirect_url)) - elif login_gov_error: - current_app.logger.error(f"login.gov error: {login_gov_error}") - raise Exception(f"Could not login with login.gov {login_gov_error}") # end login.gov diff --git a/app/templates/new/components/main_nav.html b/app/templates/new/components/main_nav.html new file mode 100644 index 000000000..a3b02823e --- /dev/null +++ b/app/templates/new/components/main_nav.html @@ -0,0 +1,30 @@ +{% if help %} + {% include 'partials/tour.html' %} +{% else %} + +{% endif %} diff --git a/app/templates/new/components/org_nav.html b/app/templates/new/components/org_nav.html new file mode 100644 index 000000000..f7f7a5b93 --- /dev/null +++ b/app/templates/new/components/org_nav.html @@ -0,0 +1,11 @@ + diff --git a/app/templates/new/components/service_navigation.html b/app/templates/new/components/service_navigation.html new file mode 100644 index 000000000..e3826d279 --- /dev/null +++ b/app/templates/new/components/service_navigation.html @@ -0,0 +1,15 @@ + diff --git a/app/templates/new/components/settings_navigation.html b/app/templates/new/components/settings_navigation.html new file mode 100644 index 000000000..d94c417e7 --- /dev/null +++ b/app/templates/new/components/settings_navigation.html @@ -0,0 +1,16 @@ +{% if help %} +{% include 'partials/tour.html' %} +{% else %} + +{% endif %} diff --git a/app/templates/new/layouts/org_template.html b/app/templates/new/layouts/org_template.html index 5e04003fd..69f49b76a 100644 --- a/app/templates/new/layouts/org_template.html +++ b/app/templates/new/layouts/org_template.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "/new/base.html" %} {% block per_page_title %} {% block org_page_title %}{% endblock %} – {{ current_org.name }} @@ -17,7 +17,7 @@
- {% include "org_nav.html" %} + {% include "/new/components/org_nav.html" %}
{% block beforeContent %} diff --git a/app/templates/new/layouts/withnav_template.html b/app/templates/new/layouts/withnav_template.html index c9aed27dc..f8bf009cd 100644 --- a/app/templates/new/layouts/withnav_template.html +++ b/app/templates/new/layouts/withnav_template.html @@ -8,7 +8,7 @@ {% block main %}
{% block serviceNavigation %} - {% include "service_navigation.html" %} + {% include "new/components/service_navigation.html" %} {% endblock %} {# The withnav_template can serve as a replacement for both settings_template and org_template.html. @@ -24,12 +24,12 @@
{% block sideNavigation %} - {% include "main_nav.html" %} - {# + {% include "/new/components/main_nav.html" %} + {# Include settings_nav.html for child templates that previously extended settings_template. Include "org_nav.html" for child templates that previously extended org_template html - #} + #} {% endblock %}
diff --git a/app/templates/new/templates_glossary.md b/app/templates/new/templates_glossary.md index 04f2c4151..1c52e75dc 100644 --- a/app/templates/new/templates_glossary.md +++ b/app/templates/new/templates_glossary.md @@ -14,6 +14,10 @@ This document serves as a glossary for the templates directory structure of the - `head.html`: Template for the site's , included in `base.html`. - `header.html`: Template for the site's header, included in `base.html`. - `footer.html`: Template for the site's footer, included in `base.html`. + - `settings_navigation.html`: The settings navigation used in `withnav_template.html` that previously extended `settings_template.html`. + - `org_nav.html`: The organization's navigation used solely in `org_template.html`. + - `main_nav.html`: The main navigation used in `withnav_template.html` + - `service_navigation.html`: The service navigation used in `withnav_template.html`. In withnav_template.html, the `serviceNavigation` block will be left empty in any child templates that previously extended `settings_template.html`. - **/views** (or **/pages**): Individual page templates that use the base layouts, components, and partials to present content. ### Best Practices @@ -30,9 +34,9 @@ This document serves as a glossary for the templates directory structure of the - withoutnav_template.html Delete - main_template.html Delete - settings_templates.html `withnav_template` can be used to replace `settings_template`. -- settings_nav.html (move to /new/navigation directory) -- main_nav.html (move to /new/navigation directory) -- service_navigation.html (move to /new/navigation directory) +- settings_nav.html (move to /components/ directory) +- main_nav.html (move to /components/ directory) +- service_navigation.html (move to /components/ directory) - org_template, could be under it's own directory called /layout/organization -- org_nav.html (move to /new/navigation directory) +- org_nav.html (move to /components/ directory) - content_template.html Delete