Gitea test works with a repository-only token

The test asked Gitea for the token's user, which needs read:user; a token
scoped to write:repository (all Supermarket needs) failed. It now checks
the websites' repositories and only names the user when it can.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 08:31:37 -07:00
co-authored by Claude Opus 5.5
parent 68c224f51b
commit bf933971dd
2 changed files with 31 additions and 3 deletions
+6 -3
View File
@@ -255,11 +255,14 @@ func (s *Server) testGitea(ctx context.Context) map[string]any {
if g == nil {
return map[string]any{"Error": "Save the token first."}
}
who, err := g.Me(ctx)
if err != nil {
// Only the repositories matter: a token scoped to write:repository can't
// read its own user, and doesn't need to.
out := "The token works."
if who, err := g.Me(ctx); err == nil && who != "" {
out = "The token works, as " + who + "."
} else if errors.Is(err, gitea.ErrUnauthorized) {
return map[string]any{"Error": err.Error()}
}
out := "The token works, as " + who + "."
var bad []string
for _, st := range s.seoSites() {
p, _ := profile.Load(s.DB)