feat(PROJ-53): Konfigurierbare Listenanzahl pro Seite
- users.list_page_size (Default 25), PATCH /api/auth/preferences, Whitelist 25/50/100/200, Wert in login/me-Response - Settings-UI mit Select, /search nutzt gespeicherte Seitengröße - /api/search page_size serverseitig auf max. 500 gecappt fix(PROJ-46): login_attempts-Migration nutzte s.db statt s.pool (Backend kompilierte nicht) feat(PROJ-50): DSGVO-Löschersuchen Backend (dsgvo_requests, Handler, cc_addr/bcc_addr Indexerweiterung) — noch nicht QA'd/deployed
This commit is contained in:
@@ -150,3 +150,45 @@ func (s *Server) handleChangeEmail(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
writeJSON(w, http.StatusOK, map[string]interface{}{"ok": true, "email": req.Email})
|
||||
}
|
||||
|
||||
// allowedListPageSizes are the valid values for users.list_page_size (PROJ-53).
|
||||
var allowedListPageSizes = map[int]bool{25: true, 50: true, 100: true, 200: true}
|
||||
|
||||
// handleChangePreferences allows a user to change their own UI preferences,
|
||||
// currently just the number of list entries shown per page.
|
||||
// PATCH /api/auth/preferences
|
||||
func (s *Server) handleChangePreferences(w http.ResponseWriter, r *http.Request) {
|
||||
sess := sessionFromCtx(r.Context())
|
||||
if sess.UserID == 0 {
|
||||
writeError(w, http.StatusUnauthorized, "not authenticated")
|
||||
return
|
||||
}
|
||||
|
||||
var req struct {
|
||||
ListPageSize int `json:"list_page_size"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
writeError(w, http.StatusBadRequest, "invalid request body")
|
||||
return
|
||||
}
|
||||
|
||||
if !allowedListPageSizes[req.ListPageSize] {
|
||||
writeError(w, http.StatusBadRequest, "invalid list_page_size: must be 25, 50, 100 or 200")
|
||||
return
|
||||
}
|
||||
|
||||
user, err := s.users.GetByUsername(sess.Username)
|
||||
if err != nil {
|
||||
s.logger.Error("change_preferences: user not found", "err", err, "username", sess.Username)
|
||||
writeError(w, http.StatusInternalServerError, "user not found")
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.users.UpdateListPageSize(r.Context(), user.ID, req.ListPageSize); err != nil {
|
||||
s.logger.Error("change_preferences: update failed", "err", err)
|
||||
writeError(w, http.StatusInternalServerError, "failed to update preferences")
|
||||
return
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, map[string]interface{}{"ok": true, "list_page_size": req.ListPageSize})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user