From 4d125501c80507564d98ea0f5ae041cbfb7f6a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Papp?= Date: Thu, 30 Jul 2026 19:29:57 +0200 Subject: [PATCH] [client] Store the account email after a GUI SSO login MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- client/ui/services/connection.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/client/ui/services/connection.go b/client/ui/services/connection.go index fae7ddd23..5423b199b 100644 --- a/client/ui/services/connection.go +++ b/client/ui/services/connection.go @@ -242,6 +242,22 @@ func (s *Connection) waitSSOLogin(ctx context.Context, p WaitSSOParams) (string, return "", s.classifyDaemonError(err) } log.Infof("SSO login completed, daemon reported success") + + // Persist the account email the same way the CLI does after its own + // WaitSSOLogin: the daemon returns it but cannot store it, since it runs as + // root and the per-profile state file is user-owned (see Logout below). + // Without this the profile has no email, so Profiles.List shows no account + // and later logins and session extends go out without a login_hint — + // leaving the IdP to guess which account was meant. + if email := resp.GetEmail(); email != "" { + if err := profilemanager.NewProfileManager().SetActiveProfileState(&profilemanager.ProfileState{ + Email: email, + }); err != nil { + // Non-fatal: the login itself succeeded. + log.Warnf("failed to store account email for the active profile: %v", err) + } + } + return resp.GetEmail(), nil }