save oauth user_id and link users and accounts
This commit is contained in:
@@ -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?
|
||||
|
||||
Reference in New Issue
Block a user