mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-17 12:19:07 +02:00
[client] Tolerate already-deleted peer on profile logout, clear stale email
logoutFromProfile failed hard when the management server returned NotFound (peer already deleted from the dashboard), blocking both profile logout and profile removal. Treat NotFound as success — the peer is already gone, so deregistering it is already satisfied. Also drop the user-side per-profile state file on logout. The account email is sourced from <profile>.state.json (written by the CLI after SSO login), which the root daemon can't reach, so logout left a stale email showing in the UI. Connection.Logout now removes it from the UI process after a successful logout; the next SSO login recreates it.
This commit is contained in:
@@ -12,8 +12,10 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
gstatus "google.golang.org/grpc/status"
|
||||
|
||||
"github.com/netbirdio/netbird/client/internal/profilemanager"
|
||||
"github.com/netbirdio/netbird/client/proto"
|
||||
"github.com/netbirdio/netbird/client/ui/i18n"
|
||||
"github.com/netbirdio/netbird/client/ui/preferences"
|
||||
@@ -339,5 +341,17 @@ func (s *Connection) Logout(ctx context.Context, p LogoutParams) error {
|
||||
if _, err = cli.Logout(ctx, req); err != nil {
|
||||
return s.classifyDaemonError(err)
|
||||
}
|
||||
|
||||
// The daemon runs as root and can't reach the user-owned per-profile state
|
||||
// file that holds the account email (see Profiles.List). Drop it here from
|
||||
// the UI process so a logged-out profile no longer shows a stale email; the
|
||||
// next SSO login recreates it.
|
||||
if p.ProfileName != "" {
|
||||
if err := profilemanager.NewProfileManager().RemoveProfileState(p.ProfileName); err != nil {
|
||||
// Non-fatal: the logout itself succeeded.
|
||||
log.Warnf("failed to remove profile state for %s: %v", p.ProfileName, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user