fix(endpoints): fall back to last-used username on first connect - #5384
Merged
norman-abramovitz merged 1 commit intoMay 27, 2026
Conversation
The per-endpoint username cache landed in c9e649a so a reconnect after disconnect could prefill the dialog. But the cache is keyed by endpoint guid, so the first connect to each newly-registered endpoint starts blank — even when the operator just connected to a sibling endpoint using the same account a moment ago. Friction for the common "register N CFs that share UAA" workflow. Add a global last-used slot (`stratos.endpoint.username.__last`) written on every successful credentials connect alongside the per-endpoint slot. The new `getRememberedUsername(guid)` helper returns the per-endpoint value when present, otherwise the global, otherwise null. forgetRememberedUsername stays per-endpoint — disconnecting one CF shouldn't blank the prefill for unrelated ones. connect-endpoint.component swaps its direct localStorage read for the helper, so the fallback applies uniformly. Empty-string handling is explicit (some happy-dom variants return '' for missing keys) — the helper treats '' as "no value" instead of trusting the chain operator. Spec coverage: per-endpoint hit, global fallback, latest-write wins, forget preserves global, empty-state returns null. Updates the two older tests that checked `localStorage.getItem(...) === null` directly — they were relying on a behavior the current happy-dom doesn't guarantee.
norman-abramovitz
approved these changes
May 27, 2026
norman-abramovitz
left a comment
Contributor
There was a problem hiding this comment.
Verified that the username is remembered across connect/disconnect to simulate a reconnect command.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends the existing per-endpoint username cache with a global last-used-username fallback. The per-endpoint cache (#5350) prefills the reconnect dialog after disconnect, but the FIRST connect to each newly-registered endpoint still starts blank — even when the operator just connected to a sibling endpoint with the same UAA account.
Real-world hit: an operator registers several CFs that share an identity provider (e.g. several Kevin tenants). First connect to each new endpoint required re-typing the same username every time.
What it does
stratos.endpoint.username.__lastwritten on every successful credentials connect alongside the existing per-endpoint keygetRememberedUsername(guid)helper returns:nullotherwiseconnect-endpoint.componentswaps its directlocalStorageread for the helper, so the fallback applies uniformlyforgetRememberedUsernamedeliberately does NOT clear the global slot — disconnecting one CF shouldn't blank the prefill for unrelated endpointsBehavior
SSO / token forms have no username control, so the prefill is a no-op for those — same as before.
Defensive change to existing tests
Two pre-existing tests asserted
localStorage.getItem(...).toBeNull()for missing keys. Some happy-dom variants return''instead ofnull, so those tests broke alongside this PR. Updated to use the new helper (which treats''andnullequivalently) or assert against both forms.Test plan
remembered-username.spec.ts(5 new for the fallback, 4 existing updated for happy-dom robustness)connect-endpoint.component.spec.tsunchanged + passesmake check gateran clean (exit 0)