fix gitea oauth

This commit is contained in:
2026-07-28 18:49:30 -05:00
parent 48f7dad599
commit 7f24b64906
10 changed files with 45 additions and 6 deletions
+4 -2
View File
@@ -5,6 +5,7 @@ import (
"database/sql"
"encoding/json"
"fmt"
"log"
"net/http"
"net/url"
"strings"
@@ -90,6 +91,7 @@ func (s *Server) handleCallback(w http.ResponseWriter, r *http.Request) {
user, err := s.exchangeOAuthCode(r.Context(), code)
if err != nil {
log.Printf("Gitea OAuth code exchange failed: %v", err)
http.Error(w, "Gitea sign-in failed", http.StatusBadGateway)
return
}
@@ -154,7 +156,7 @@ func (s *Server) exchangeOAuthCode(ctx context.Context, code string) (giteaUser,
request, err := http.NewRequestWithContext(
ctx,
http.MethodPost,
joinURL(s.cfg.GiteaURL, "/login/oauth/access_token"),
joinURL(s.cfg.GiteaInternalURL, "/login/oauth/access_token"),
strings.NewReader(form.Encode()),
)
if err != nil {
@@ -181,7 +183,7 @@ func (s *Server) exchangeOAuthCode(ctx context.Context, code string) (giteaUser,
request, err = http.NewRequestWithContext(
ctx,
http.MethodGet,
joinURL(s.cfg.GiteaURL, "/api/v1/user"),
joinURL(s.cfg.GiteaInternalURL, "/api/v1/user"),
nil,
)
if err != nil {