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
+27
View File
@@ -0,0 +1,27 @@
package site
import (
"fmt"
"net/http"
)
// POST /accounts
func (s *Server) createAccount(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
email := r.FormValue("email")
if email == "" {
http.Error(w, "no email provided", http.StatusBadRequest)
return
}
userID := getAccessTokenClaims(ctx).Subject
acct, err := s.accts.CreateAccount(ctx, userID, email)
if err != nil {
http.Error(w, fmt.Sprintf("failed to create account: %v", err), http.StatusInternalServerError)
return
}
//http.Redirect(w, r, fmt.Sprintf("/site/accounts/%d", acct.ID), http.StatusSeeOther)
http.Redirect(w, r, fmt.Sprintf("/accounts/%d", acct.ID), http.StatusSeeOther)
}