Fix image formats and size, add feedback
This commit is contained in:
1 parent
feaab7e4e2
commit
fef1abade8
11 files changed
+192
-12
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package rest
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"goAuth/internal/user"
|
||||
)
|
||||
|
||||
// avatarLimitsResponse describes the constraints applied to avatar uploads so
|
||||
// the frontend can mirror them (file picker filter, size hint and client-side
|
||||
// pre-validation) without hardcoding values.
|
||||
type avatarLimitsResponse struct {
|
||||
MaxSizeBytes int `json:"maxSizeBytes"`
|
||||
MaxWidth int `json:"maxWidth"`
|
||||
MaxHeight int `json:"maxHeight"`
|
||||
AllowedMimeTypes []string `json:"allowedMimeTypes"`
|
||||
}
|
||||
|
||||
type configResponse struct {
|
||||
Avatar avatarLimitsResponse `json:"avatar"`
|
||||
}
|
||||
|
||||
// getConfig exposes public, non-secret limits used by the frontend. It is
|
||||
// served on the public chain so the CSRF cookie is seeded on this GET request
|
||||
// as well.
|
||||
func (h *Handler) getConfig(w http.ResponseWriter, r *http.Request) {
|
||||
writeJson(w, http.StatusOK, configResponse{
|
||||
Avatar: avatarLimitsResponse{
|
||||
MaxSizeBytes: user.MaxImageSize,
|
||||
MaxWidth: user.MaxImageWidth,
|
||||
MaxHeight: user.MaxImageHeight,
|
||||
AllowedMimeTypes: user.AllowedAvatarMIMETypes(),
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user