Skip to content

Me/dpc 5451 last used csp indicator#3015

Open
MEspositoE14s wants to merge 9 commits into
mainfrom
me/dpc-5451-last-used-csp-indicator
Open

Me/dpc 5451 last used csp indicator#3015
MEspositoE14s wants to merge 9 commits into
mainfrom
me/dpc-5451-last-used-csp-indicator

Conversation

@MEspositoE14s
Copy link
Copy Markdown
Contributor

🎫 Ticket

https://jira.cms.gov/browse/DPC-5451

🛠 Changes

  • Added "Last Used" CSP indicator at login screen.
  • Added "Last Used" CSP toggle to LookBook preview.

ℹ️ Context

When a user comes back to our site, we want to highlight the CSP they last used to login.

On a successful login we write a cookie named last_used_csp. If that cookie is present when the user returns to the login page, we use it to highlight the CSP as "Last Used".

🧪 Validation

  • Deployed to dev here.
  • Ran locally.
  • All tests passing.

Currently, only Login.gov is supported in the dpc-portal. If you want to see how the other CSPs look you have two options:

  1. Just use LookBook. There's a drop down parameter that lets you set which CSP should be "Last Used".
  2. Run locally, go the the login page, and then open your browser's developer mode and edit the last_used_csp cookie.
image

@MEspositoE14s MEspositoE14s requested a review from a team as a code owner May 26, 2026 16:56
Comment thread dpc-portal-test.sh
echo "└────────────────────────-----───┘"

docker compose -p start-v1-portals -f docker-compose.yml -f docker-compose.portals.yml run --entrypoint "bundle exec rubocop" dpc_portal
docker compose -p start-v1-portals -f docker-compose.yml -f docker-compose.portals.yml run --entrypoint "rails assets:clobber tmp:clear" dpc_portal
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this because the asset cache isn't getting rebuilt between CI runs on our code builders, and it causes tests to fail whenever we need to add an image somewhere. This forces it in CI.

<%= button_to @login_path, class: 'usa-button width-full margin-bottom-1', data: { turbo: false } do %>
<span class="clear-login-button__logo">CLEAR</span>
<% end %>
<% if @last_used_csp == :clear%>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to avoid conditionals for both opening and closing <div> tags. New component isn't required, but I'm almost certain you can achieve what you want by conditionally applying the class here

e.g.

<%= idp_login_button  login_path, is_last_used, ... %>

then the idp_login_button includes

<div <% if is_last_used %>class="last-used-login-wrapper margin-bottom-1"<% endif %> >
            <%= button_to @login_path, class: 'usa-button width-full margin-bottom-1', data: { turbo: false } do %>
            <span class="{{ csp }}-login-button__logo">{{ csp }}</span>
</div>

Copy link
Copy Markdown
Contributor Author

@MEspositoE14s MEspositoE14s May 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That code was kind of ugly, and your suggestion was a good idea that sent me down a rabbit hole trying to see how clean and streamlined I could make this bit of code.

expect(page).not_to have_css('.last-used-login-wrapper .lg-login-button__logo')
end
end
end
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@MEspositoE14s MEspositoE14s requested review from a team and lukey-luke May 26, 2026 20:52
lukey-luke
lukey-luke previously approved these changes May 26, 2026
Copy link
Copy Markdown
Contributor

@lukey-luke lukey-luke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Jose-verdance
Copy link
Copy Markdown
Contributor

Jose-verdance commented May 28, 2026

Hey @MEspositoE14s, I tried testing your changes locally but I am getting this message from what looks like a comment.
Screenshot 2026-05-28 at 10 00 34 AM

i think you can use either html comment <!-- Build a login button for each CSP --> or erb <%# Build a login button for each CSP %>

@MEspositoE14s
Copy link
Copy Markdown
Contributor Author

Hey @MEspositoE14s, I tried testing your changes locally but I am getting this message from what looks like a comment. Screenshot 2026-05-28 at 10 00 34 AM

i think you can use either html comment <!-- Build a login button for each CSP --> or erb <%# Build a login button for each CSP %>

Doh! I added this in the last commit and it was a total brain fart on my part. This is what happens when you jump between languages too often 😞

@MEspositoE14s MEspositoE14s requested review from a team and lukey-luke May 28, 2026 14:22
@Jose-verdance
Copy link
Copy Markdown
Contributor

Doh! I added this in the last commit and it was a total brain fart on my part. This is what happens when you jump between languages too often 😞

No worries, that context switching can be brutal!

Copy link
Copy Markdown
Contributor

@Jose-verdance Jose-verdance left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@MEspositoE14s MEspositoE14s requested a review from a team May 29, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants