From 4eea326f69851eb247092eeebe9b86ca4cce859a Mon Sep 17 00:00:00 2001 From: ahnbu Date: Wed, 11 Mar 2026 14:28:40 +0900 Subject: [PATCH] fix(auth): doctor reads token from current profile After profile-based login, cfg.Token is empty because MigrateToProfiles clears it. doctor was only checking the legacy top-level token field, causing it to always report 'no token found' even after a successful login. Fixes #5 --- cmd/auth.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/auth.go b/cmd/auth.go index 86b174a..a0a535b 100644 --- a/cmd/auth.go +++ b/cmd/auth.go @@ -348,7 +348,12 @@ Examples: // Check 1: Config file cfg, err := config.Load() - if err != nil || cfg.Token == "" { + profile := cfg.GetCurrentProfile() + token := cfg.Token + if token == "" && profile != nil { + token = profile.Token + } + if err != nil || token == "" { fmt.Println(" ✗ Config: no token found") fmt.Println(" Run: notion auth login --with-token") return nil @@ -356,7 +361,7 @@ Examples: fmt.Println(" ✓ Config: token found") // Check 2: Token validity - c := client.New(cfg.Token) + c := client.New(token) me, err := c.GetMe() if err != nil { fmt.Printf(" ✗ Auth: token is invalid (%v)\n", err)