[PR #6986] [MERGED] [client] Keep the account email backing the SSO login hint correct #30065

Closed
opened 2026-08-05 08:09:57 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6986
Author: @pappz
Created: 7/30/2026
Status: Merged
Merged: 8/3/2026
Merged by: @pappz

Base: mainHead: fix/gui-store-login-hint


📝 Commits (5)

  • 4d12550 [client] Store the account email after a GUI SSO login
  • 6f8d028 [client] File the account email against the profile the login ran for
  • 9ebf10b [client] Delete the account email when a profile is removed
  • eac9a1b [client] Clear the removed profile's email by its resolved ID
  • c0a1d95 [client] Report the login's profile ID only when it is one

📊 Changes

4 files changed (+95 additions, -16 deletions)

View changed files

📝 client/internal/profilemanager/state.go (+24 -12)
📝 client/ui/frontend/src/lib/connection.ts (+7 -2)
📝 client/ui/services/connection.go (+40 -0)
📝 client/ui/services/profile.go (+24 -2)

📄 Description

Describe your changes

Three fixes to how the desktop GUI keeps the account email that backs the SSO login_hint. Each is independent and reviewable on its own.

1. Store the email after a GUI SSO login

The daemon returns the authenticated user's email from WaitSSOLogin but cannot persist it: it runs as root while the per-profile state file is user-owned. The CLI's handleSSOLogin writes it after its own WaitSSOLogin; the GUI path read the value and dropped it.

The profile was therefore left with no email, so Profiles.List showed no account for it, and later logins and session extends went out with no login_hint — leaving the IdP to pick an account instead of reusing the one the profile belongs to. Mirror the CLI and store it, next to the Logout path that already clears the same file for the same reason.

2. File the email against the profile the login ran for

SetActiveProfileState resolves the target itself, so it writes to whichever profile is active when it is called. A GUI SSO login spans seconds of user interaction in the browser, and the tray stays clickable throughout: switching profiles in that window left the email filed under the profile that happened to be active when the flow returned. The wrong profile then advertised an account it does not own, and offered it as the login_hint next time.

Adds SetProfileState(id, state), the write-side counterpart of the existing GetProfileState(id), and keeps SetActiveProfileState as a wrapper for callers with no particular profile in mind. Login now reports the profile it resolved so the frontend can hand it back with the SSO wait, which closes the window.

3. Delete the email when a profile is removed

Removing a profile left its state file behind: the daemon deletes what it owns, but the email file is user-owned and out of reach for a root daemon — the same split that already puts the Logout cleanup on the UI side.

Beyond the stray file, legacy profiles are keyed by name rather than by a generated ID, so recreating a profile under a removed one's name inherited its email — shown as the account in the profile list and sent as the login_hint on the next login.

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • This change does not modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — OR I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See CONTRIBUTING.md.

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__

Summary by CodeRabbit

  • New Features

    • SSO login details can now be saved to the specific profile selected during sign-in.
    • Profile state can be managed independently for different profiles.
  • Bug Fixes

    • Removing a profile now also cleans up its associated saved state.
    • Cleanup issues no longer prevent successful profile removal and are handled gracefully.
    • Existing active-profile behavior remains unchanged.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/6986 **Author:** [@pappz](https://github.com/pappz) **Created:** 7/30/2026 **Status:** ✅ Merged **Merged:** 8/3/2026 **Merged by:** [@pappz](https://github.com/pappz) **Base:** `main` ← **Head:** `fix/gui-store-login-hint` --- ### 📝 Commits (5) - [`4d12550`](https://github.com/netbirdio/netbird/commit/4d125501c80507564d98ea0f5ae041cbfb7f6a26) [client] Store the account email after a GUI SSO login - [`6f8d028`](https://github.com/netbirdio/netbird/commit/6f8d0289c0ff5ff4751d988e3ecba0eea4c92a0b) [client] File the account email against the profile the login ran for - [`9ebf10b`](https://github.com/netbirdio/netbird/commit/9ebf10be416dfb91d812c09e3397a565cfd3d90d) [client] Delete the account email when a profile is removed - [`eac9a1b`](https://github.com/netbirdio/netbird/commit/eac9a1b6f7cb4779e7341eae585783c98717ec86) [client] Clear the removed profile's email by its resolved ID - [`c0a1d95`](https://github.com/netbirdio/netbird/commit/c0a1d95fc7054a9642dd8eab4786addd36d4f5fd) [client] Report the login's profile ID only when it is one ### 📊 Changes **4 files changed** (+95 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `client/internal/profilemanager/state.go` (+24 -12) 📝 `client/ui/frontend/src/lib/connection.ts` (+7 -2) 📝 `client/ui/services/connection.go` (+40 -0) 📝 `client/ui/services/profile.go` (+24 -2) </details> ### 📄 Description ## Describe your changes Three fixes to how the desktop GUI keeps the account email that backs the SSO `login_hint`. Each is independent and reviewable on its own. **1. Store the email after a GUI SSO login** The daemon returns the authenticated user's email from `WaitSSOLogin` but cannot persist it: it runs as root while the per-profile state file is user-owned. The CLI's `handleSSOLogin` writes it after its own `WaitSSOLogin`; the GUI path read the value and dropped it. The profile was therefore left with no email, so `Profiles.List` showed no account for it, and later logins and session extends went out with no `login_hint` — leaving the IdP to pick an account instead of reusing the one the profile belongs to. Mirror the CLI and store it, next to the `Logout` path that already clears the same file for the same reason. **2. File the email against the profile the login ran for** `SetActiveProfileState` resolves the target itself, so it writes to whichever profile is active when it is called. A GUI SSO login spans seconds of user interaction in the browser, and the tray stays clickable throughout: switching profiles in that window left the email filed under the profile that happened to be active when the flow returned. The wrong profile then advertised an account it does not own, and offered it as the `login_hint` next time. Adds `SetProfileState(id, state)`, the write-side counterpart of the existing `GetProfileState(id)`, and keeps `SetActiveProfileState` as a wrapper for callers with no particular profile in mind. `Login` now reports the profile it resolved so the frontend can hand it back with the SSO wait, which closes the window. **3. Delete the email when a profile is removed** Removing a profile left its state file behind: the daemon deletes what it owns, but the email file is user-owned and out of reach for a root daemon — the same split that already puts the `Logout` cleanup on the UI side. Beyond the stray file, legacy profiles are keyed by name rather than by a generated ID, so recreating a profile under a removed one's name inherited its email — shown as the account in the profile list and sent as the `login_hint` on the next login. ## Issue ticket number and link ## Stack <!-- branch-stack --> ### Checklist - [x] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) - [ ] This change does **not** modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — **OR** I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See [CONTRIBUTING.md](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTING.md#discuss-changes-with-the-netbird-team-first). > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: https://github.com/netbirdio/docs/pull/__ <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - SSO login details can now be saved to the specific profile selected during sign-in. - Profile state can be managed independently for different profiles. - **Bug Fixes** - Removing a profile now also cleans up its associated saved state. - Cleanup issues no longer prevent successful profile removal and are handled gracefully. - Existing active-profile behavior remains unchanged. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 08:09:57 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#30065