fix(auth): resolve compile errors in timezone update handler
The timezone update block in UpdateProfile() referenced undefined variables ctx and userUUID, causing a compile error. Fixed to use c.Request().Context() and targetUserUUID which are the correct variables in that handler scope. Also added Timezone field to AdminUpdateUserRequest struct so the timezone value is properly bound from JSON requests, since UpdateProfile() binds to AdminUpdateUserRequest rather than UpdateProfileRequest.
This commit is contained in:
1 parent
55a9ec00e1
commit
5be6fec408
1 file changed
+3
-2
@@ -96,6 +96,7 @@ type AdminUpdateUserRequest struct {
|
||||
FirstName string `json:"first_name,omitempty" validate:"omitempty,max=100"`
|
||||
LastName string `json:"last_name,omitempty" validate:"omitempty,max=100"`
|
||||
Theme string `json:"theme,omitempty" validate:"omitempty"`
|
||||
Timezone string `json:"timezone,omitempty" validate:"omitempty"`
|
||||
Role string `json:"role,omitempty" validate:"omitempty,oneof=user admin"`
|
||||
}
|
||||
|
||||
@@ -572,8 +573,8 @@ func (h *AuthHandler) UpdateProfile(c *echo.Context) error {
|
||||
"error": "Invalid timezone",
|
||||
})
|
||||
}
|
||||
err := h.db.UpdateUserTimezone(ctx, database.UpdateUserTimezoneParams{
|
||||
ID: pgtype.UUID{Bytes: userUUID, Valid: true},
|
||||
err := h.db.UpdateUserTimezone(c.Request().Context(), database.UpdateUserTimezoneParams{
|
||||
ID: targetUserUUID,
|
||||
Timezone: pgtype.Text{String: req.Timezone, Valid: true},
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user