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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user