diff --git a/src/docker-compose.yml b/src/docker-compose.yml index d104a4c15..50c29802b 100644 --- a/src/docker-compose.yml +++ b/src/docker-compose.yml @@ -26,7 +26,7 @@ services: # Run Django in debug mode on local - DJANGO_DEBUG=True # Tell Django where it is being hosted - - DJANGO_BASE_URL="localhost:8080" + - DJANGO_BASE_URL=http://localhost:8080 # --- These keys are obtained from `.env` file --- # Set a private JWT signing key for Login.gov - DJANGO_SECRET_LOGIN_KEY diff --git a/src/registrar/assets/sass/_theme/_uswds-theme-custom-styles.scss b/src/registrar/assets/sass/_theme/_uswds-theme-custom-styles.scss index aab929a51..c176ed937 100644 --- a/src/registrar/assets/sass/_theme/_uswds-theme-custom-styles.scss +++ b/src/registrar/assets/sass/_theme/_uswds-theme-custom-styles.scss @@ -22,8 +22,7 @@ i.e. @use "uswds-core" as *; -// Test custom style -p { - color: color('blue-10v'); -} - +// Test custom style (except this has not enough contrast) +//p { +// color: color('blue-10v'); +//} diff --git a/src/registrar/config/settings.py b/src/registrar/config/settings.py index 93293073c..cda2f14bc 100644 --- a/src/registrar/config/settings.py +++ b/src/registrar/config/settings.py @@ -164,6 +164,7 @@ TEMPLATES = [ "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", "registrar.context_processors.language_code", + "registrar.context_processors.canonical_path", ], }, }, @@ -379,7 +380,7 @@ AUTHENTICATION_BACKENDS = [ # this is where unauthenticated requests are redirected when using # the login_required() decorator, LoginRequiredMixin, or AccessMixin -LOGIN_URL = "openid/openid/login" +LOGIN_URL = "openid/login" # where to go after logging out LOGOUT_REDIRECT_URL = "home" @@ -405,10 +406,8 @@ OIDC_PROVIDERS = { }, "client_registration": { "client_id": "cisa_dotgov_registrar", - "redirect_uris": [f"https://{env_base_url}/openid/callback/login/"], - "post_logout_redirect_uris": [ - f"https://{env_base_url}/openid/callback/logout/" - ], + "redirect_uris": [f"{env_base_url}/openid/callback/login/"], + "post_logout_redirect_uris": [f"{env_base_url}/openid/callback/logout/"], "token_endpoint_auth_method": ["private_key_jwt"], "sp_private_key": secret_login_key, }, diff --git a/src/registrar/config/urls.py b/src/registrar/config/urls.py index 699575f5d..0a9ff6da9 100644 --- a/src/registrar/config/urls.py +++ b/src/registrar/config/urls.py @@ -7,10 +7,11 @@ For more information see: from django.contrib import admin from django.urls import include, path -from registrar.views import health, index, profile +from registrar.views import health, index, profile, whoami urlpatterns = [ path("", index.index, name="home"), + path("whoami", whoami.whoami, name="whoami"), path("admin/", admin.site.urls), path("health/", health.health), path("edit_profile/", profile.edit_profile, name="edit-profile"), diff --git a/src/registrar/context_processors.py b/src/registrar/context_processors.py index 6e104b66d..38f058b93 100644 --- a/src/registrar/context_processors.py +++ b/src/registrar/context_processors.py @@ -11,3 +11,13 @@ def language_code(request): TEMPLATES dict of our settings file). """ return {"LANGUAGE_CODE": settings.LANGUAGE_CODE} + + +def canonical_path(request): + """Add a canonical URL to the template context. + + To make a correct "rel=canonical" link in the HTML page, we need to + construct an absolute URL for the page, and we can't do that in the + template itself, so we do it here and pass the information on. + """ + return {"CANONICAL_PATH": request.build_absolute_uri(request.path)} diff --git a/src/registrar/templates/base.html b/src/registrar/templates/base.html index 3c303013d..679fe527f 100644 --- a/src/registrar/templates/base.html +++ b/src/registrar/templates/base.html @@ -7,28 +7,26 @@ {% block title %}{% endblock %} - {{ site.name }} + .gov Registrar {% block extra_title %}{% endblock %} {% block viewport_meta %} - + {% endblock %} {% block extra_meta %}{% endblock extra_meta %} - {# TO-DO: Determine if is desirable #} - {# TO-DO: set defaults for these #} {% block css %} - - + + {% endblock %} {% block canonical %} - + {% endblock %} @@ -49,154 +47,136 @@ Skip to main content -
-
-
-
-
- U.S. flag -
-
-

- An official website of the United States government -

- -
- -
-
-
-
-
- -
-

- Official websites use .gov
A - .gov website belongs to an official government - organization in the United States. +

+
+
+
+
+ U.S. flag +
+
+

+ An official website of the United States government +

+
+
-
- -
-

- Secure .gov websites use HTTPS
A - lock ( - - - - - ) or https:// means you’ve safely connected to - the .gov website. Share sensitive information only on official, - secure websites. -

+
+
+
+
+ +
+

+ Official websites use .gov
A + .gov website belongs to an official government + organization in the United States. +

+
+
+
+ +
+

+ Secure .gov websites use HTTPS
A + lock ( + + + + + ) or https:// means you’ve safely connected to + the .gov website. Share sensitive information only on official, + secure websites. +

+
-
-
+ {% block banner %} - {% endblock banner %} {% block usa_overlay %}
{% endblock %}
- {% block messages %} - {% if messages %} - - {% endif %} - {% endblock %} + {% block messages %} + {% if messages %} + + {% endif %} + {% endblock %} - {% block section_nav %}{% endblock %} + {% block section_nav %}{% endblock %} -
- {% block hero %}{% endblock %} - {% block content %}{% endblock %} -
+
+ {% block hero %}{% endblock %} + {% block content %}{% endblock %} +
-
{% block complementary %}{% endblock %}
+
{% block complementary %}{% endblock %}
- {% block content_bottom %}{% endblock %} + {% block content_bottom %}{% endblock %} +
+ + {% block init_js %}{% endblock %}{# useful for vars and other initializations #} @@ -208,8 +188,6 @@ {% block extrascript %}{% endblock %} - {# asynchronous analytics #} - + diff --git a/src/registrar/templates/home.html b/src/registrar/templates/home.html index 14b0164ed..f6601d25c 100644 --- a/src/registrar/templates/home.html +++ b/src/registrar/templates/home.html @@ -3,21 +3,20 @@ {% block title %} Hello {% endblock %} {% block hero %} -
-
-
-

- Welcome to the .gov registrar -

+
+
+
+

+ Welcome to the .gov registrar +

-
+
{% endblock %} {% block content %}

This is the .gov registrar.

{% if user.is_authenticated %} -

Hello {{ user.id }}

Click here to log out.

{% else %}

Click here to log in.

diff --git a/src/registrar/templates/whoami.html b/src/registrar/templates/whoami.html index 9ad156c33..7fde3f786 100644 --- a/src/registrar/templates/whoami.html +++ b/src/registrar/templates/whoami.html @@ -2,17 +2,8 @@ {% extends 'base.html' %} {% block title %} Hello {% endblock %} -{% block hero %} -
-
-
-

- This is sample content. - This is only sample content. -

-

{{ name }} You'll want to replace it with content of your own.

- -
-
-
+{% block content %} +

Hello {{ user.last_name|default:"No last name given" }}, {{ user.first_name|default:"No first name given" }} <{{ user.email }}>!

+ +

Click here to log out

{% endblock %} diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py index e5becbdf0..7209c12b4 100644 --- a/src/registrar/tests/test_views.py +++ b/src/registrar/tests/test_views.py @@ -2,14 +2,25 @@ from django.test import Client, TestCase from django.contrib.auth import get_user_model -class HealthTest(TestCase): +class TestViews(TestCase): def setUp(self): self.client = Client() def test_health_check_endpoint(self): response = self.client.get("/health/") - self.assertEqual(response.status_code, 200) - self.assertContains(response, "OK") + self.assertContains(response, "OK", status_code=200) + + def test_home_page(self): + """Home page should be available without a login.""" + response = self.client.get("/") + self.assertContains(response, "registrar", status_code=200) + self.assertContains(response, "log in") + + def test_whoami_page_no_user(self): + """Whoami page not accessible without a logged-in user.""" + response = self.client.get("/whoami") + self.assertEqual(response.status_code, 302) + self.assertIn("?next=/whoami", response.headers["Location"]) class LoggedInTests(TestCase): @@ -23,6 +34,13 @@ class LoggedInTests(TestCase): ) self.client.force_login(self.user) + def test_whoami_page(self): + """User information appears on the whoami page.""" + response = self.client.get("/whoami") + self.assertContains(response, self.user.first_name) + self.assertContains(response, self.user.last_name) + self.assertContains(response, self.user.email) + def test_edit_profile(self): response = self.client.get("/edit_profile/") self.assertContains(response, "Display Name") diff --git a/src/registrar/views/index.py b/src/registrar/views/index.py index 6fd69f61f..e4acc7818 100644 --- a/src/registrar/views/index.py +++ b/src/registrar/views/index.py @@ -2,5 +2,5 @@ from django.shortcuts import render def index(request): - context = {"name": "World!"} - return render(request, "whoami.html", context) + """This page is available to anyone without logging in.""" + return render(request, "home.html") diff --git a/src/registrar/views/whoami.py b/src/registrar/views/whoami.py new file mode 100644 index 000000000..20bde778b --- /dev/null +++ b/src/registrar/views/whoami.py @@ -0,0 +1,8 @@ +from django.shortcuts import render +from django.contrib.auth.decorators import login_required + + +@login_required +def whoami(request): + """This is the first page someone goes to after logging in.""" + return render(request, "whoami.html")