feat: auth user feedbacks
This commit is contained in:
@@ -68,3 +68,21 @@ func (h *FeedbackHandler) Submit(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
response.JSON(w, http.StatusCreated, f)
|
||||
}
|
||||
|
||||
// Mine returns the authenticated caller's own feedback submissions,
|
||||
// newest first — each with its status (acknowledged / resolved) and any
|
||||
// admin reply. Registered under RequireAuth, so UserID is always set;
|
||||
// the guard is belt-and-suspenders.
|
||||
func (h *FeedbackHandler) Mine(w http.ResponseWriter, r *http.Request) {
|
||||
uid := middleware.UserID(r.Context())
|
||||
if uid == "" {
|
||||
response.Error(w, http.StatusUnauthorized, "authentication required")
|
||||
return
|
||||
}
|
||||
items, err := h.svc.ListForUser(r.Context(), uid, 50)
|
||||
if err != nil {
|
||||
response.Error(w, http.StatusInternalServerError, "could not load your feedback")
|
||||
return
|
||||
}
|
||||
response.JSON(w, http.StatusOK, items)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user