fix: auth-decisions (follow gh: auth status exit code and GITEA_TOKEN account)

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-18 18:57:25 +02:00
1 parent 20b9b1a2c1
commit 9ce014bc75
5 files changed
+57 -11

No files matched your search

+9 -2
View File
@@ -186,8 +186,10 @@ func (a *application) connect(ctx context.Context, req targetRequest) (target, e
if err != nil {
return t, err
}
// The message must not reveal which account the token belongs to.
if !services.MatchAccount(t.User, actual) {
// Like GH_TOKEN, the token overrides the stored credentials whichever account is active;
// only an account that --user or TEA_USER names must match. The message must not reveal
// which account the token belongs to.
if t.explicitUser() && !services.MatchAccount(t.User, actual) {
return t, clierr.Wrap(clierr.Authentication, errEnvironmentAccount)
}
if t.User == "" {
@@ -425,6 +427,11 @@ func (a *application) selectAccount(ctx context.Context, t *target, s settings.S
return nil
}
// explicitUser reports whether the user named the account with --user or TEA_USER.
func (t target) explicitUser() bool {
return t.User != "" && (t.UserSource == "--user" || t.UserSource == "TEA_USER")
}
// accountError explains why user has no stored credential on the target's instance.
func (t target) accountError(user string) error {
users := t.host.Users