Refactored user/volunteer/participant identity.

This commit is contained in:
Pen Anderson 2026-03-10 14:08:00 -05:00
parent e640bf8bed
commit 1eb6a99ff6
28 changed files with 469 additions and 265 deletions

View file

@ -7,7 +7,7 @@ import (
func (app *App) handleLogin(w http.ResponseWriter, r *http.Request) {
var body struct {
Username string `json:"username"`
Email string `json:"email"`
Password string `json:"password"`
}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
@ -15,7 +15,7 @@ func (app *App) handleLogin(w http.ResponseWriter, r *http.Request) {
return
}
user, hash, err := app.getUserByUsername(body.Username)
user, hash, err := app.getLoginParticipant(body.Email)
if err != nil {
writeError(w, "internal error", http.StatusInternalServerError)
return
@ -40,9 +40,9 @@ func (app *App) handleLogout(w http.ResponseWriter, r *http.Request) {
func (app *App) handleMe(w http.ResponseWriter, r *http.Request) {
claims := claimsFromContext(r)
user, err := app.getUserByID(claims.UserID)
user, err := app.getUser(claims.ParticipantID)
if err != nil || user == nil {
writeError(w, "not found", http.StatusNotFound)
writeError(w, "unauthorized", http.StatusUnauthorized)
return
}
writeJSON(w, user)