chore(auth): drop dead UpdateProfileRequest; rename shared struct

The combined profile handler (self-edit PUT /api/auth/profile and
admin PUT /api/auth/profile/:id) binds one struct for both paths —
and it's the admin-named one. Its twin UpdateProfileRequest had zero
references left. Delete it and rename AdminUpdateUserRequest to
ProfileUpdateRequest so the name matches who actually binds it; the
comments describing field semantics now stand on their own instead of
pointing at the deleted twin. Wire format (json/form tags) unchanged;
docs schema registration follows the rename.
This commit is contained in:
John O'Keefe committed 2026-10-26 13:59:22 -04:00
1 parent 649f821850
commit bdb9132b85
2 files changed
+5 -16

No files matched your search

+1 -1
View File
@@ -705,7 +705,7 @@ var Schemas = map[string]Schema{
}, },
"PUT /api/auth/profile": { "PUT /api/auth/profile": {
// Shared with admin variant (PUT /auth/profile/:id). // Shared with admin variant (PUT /auth/profile/:id).
Request: handlers.AdminUpdateUserRequest{}, Request: handlers.ProfileUpdateRequest{},
Response: json.RawMessage(`{"message": ""}`), Response: json.RawMessage(`{"message": ""}`),
}, },
"DELETE /api/auth/profile": { "DELETE /api/auth/profile": {
+4 -15
View File
@@ -124,19 +124,7 @@ type UserProfile struct {
DefaultAudioSpeed float64 `json:"default_audio_speed,omitempty"` DefaultAudioSpeed float64 `json:"default_audio_speed,omitempty"`
} }
type UpdateProfileRequest struct { type ProfileUpdateRequest struct {
Username string `json:"username,omitempty" form:"username" validate:"omitempty,min=3,max=50"`
Email string `json:"email,omitempty" form:"email" validate:"omitempty,email"`
FirstName string `json:"first_name,omitempty" form:"first_name" validate:"omitempty,max=100"`
LastName string `json:"last_name,omitempty" form:"last_name" validate:"omitempty,max=100"`
Theme string `json:"theme,omitempty" form:"theme" validate:"omitempty"`
Timezone string `json:"timezone,omitempty" form:"timezone" validate:"omitempty"`
// Per the SPEEDS list bounds; the profile select always sends it,
// JSON clients omit it (0 = untouched).
DefaultAudioSpeed float64 `json:"default_audio_speed,omitempty" form:"default_audio_speed" validate:"omitempty,min=0.25,max=4"`
}
type AdminUpdateUserRequest struct {
Username string `json:"username,omitempty" form:"username" validate:"omitempty,min=3,max=50"` Username string `json:"username,omitempty" form:"username" validate:"omitempty,min=3,max=50"`
Email string `json:"email,omitempty" form:"email" validate:"omitempty,email"` Email string `json:"email,omitempty" form:"email" validate:"omitempty,email"`
FirstName string `json:"first_name,omitempty" form:"first_name" validate:"omitempty,max=100"` FirstName string `json:"first_name,omitempty" form:"first_name" validate:"omitempty,max=100"`
@@ -144,7 +132,8 @@ type AdminUpdateUserRequest struct {
Theme string `json:"theme,omitempty" form:"theme" validate:"omitempty"` Theme string `json:"theme,omitempty" form:"theme" validate:"omitempty"`
Timezone string `json:"timezone,omitempty" form:"timezone" validate:"omitempty"` Timezone string `json:"timezone,omitempty" form:"timezone" validate:"omitempty"`
Role string `json:"role,omitempty" form:"role" validate:"omitempty,oneof=user admin"` Role string `json:"role,omitempty" form:"role" validate:"omitempty,oneof=user admin"`
// Same semantics as UpdateProfileRequest.DefaultAudioSpeed. // Per the SPEEDS list bounds; the profile select always sends it,
// JSON clients omit it (0 = untouched).
DefaultAudioSpeed float64 `json:"default_audio_speed,omitempty" form:"default_audio_speed" validate:"omitempty,min=0.25,max=4"` DefaultAudioSpeed float64 `json:"default_audio_speed,omitempty" form:"default_audio_speed" validate:"omitempty,min=0.25,max=4"`
} }
@@ -581,7 +570,7 @@ func (h *AuthHandler) UpdateProfile(c *echo.Context) error {
targetUserUUID = currentUser.ID targetUserUUID = currentUser.ID
} }
var req AdminUpdateUserRequest var req ProfileUpdateRequest
if err := c.Bind(&req); err != nil { if err := c.Bind(&req); err != nil {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid request"}) return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid request"})
} }