1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-11-25 23:52:32 +02:00

make use of the after hook finalizer

This commit is contained in:
Gani Georgiev
2023-07-18 15:31:36 +03:00
parent 624b443f98
commit d9e1a759a1
7 changed files with 82 additions and 127 deletions

View File

@@ -63,16 +63,14 @@ func (api *settingsApi) set(c echo.Context) error {
return NewBadRequestError("An error occurred while submitting the form.", err)
}
if err := api.app.OnSettingsAfterUpdateRequest().Trigger(event); err != nil {
return err
}
return api.app.OnSettingsAfterUpdateRequest().Trigger(event, func(e *core.SettingsUpdateEvent) error {
redactedSettings, err := api.app.Settings().RedactClone()
if err != nil {
return NewBadRequestError("", err)
}
redactedSettings, err := api.app.Settings().RedactClone()
if err != nil {
return NewBadRequestError("", err)
}
return e.HttpContext.JSON(http.StatusOK, redactedSettings)
return e.HttpContext.JSON(http.StatusOK, redactedSettings)
})
})
}
})