save oauth user_id and link users and accounts

This commit is contained in:
2025-12-30 02:06:14 -07:00
parent bc592718bf
commit 8090a6f25e
21 changed files with 468 additions and 198 deletions
+21
View File
@@ -7,12 +7,25 @@ import (
"path"
"path/filepath"
"strings"
"ruben/inventory2/internal/domains/accounts"
)
// GET /
func (s *Server) serveTemplates(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
name, pathParams := getPageTemplateNameForURL(r.URL)
var (
acct accounts.Account
userID string
)
claims, ok := s.getAccessTokenClaims(r)
if ok {
userID = claims.Subject
acct, _ = s.accts.GetAccountByUserID(ctx, userID)
}
b, err := s.templater.ExecutePage(
name,
"Request",
@@ -28,6 +41,14 @@ func (s *Server) serveTemplates(w http.ResponseWriter, r *http.Request) {
s.accts.WithContext(ctx),
"Etsy",
s.etsy.WithContext(ctx),
// claims
"Claims",
claims,
"UserID",
userID,
"Account",
acct,
)
if err != nil {
// TODO: handle 'not found' as a 404?