feat(admin): added admin panel
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"gitea.mrixs.me/minecraft-platform/backend/internal/core"
|
||||
"gitea.mrixs.me/minecraft-platform/backend/internal/database"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
@@ -39,11 +40,18 @@ func (h *ProfileHandler) GetProfile(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (h *ProfileHandler) UploadSkin(w http.ResponseWriter, r *http.Request) {
|
||||
userID, ok := r.Context().Value(UserIDContextKey).(int)
|
||||
// Получаем claims из контекста
|
||||
claims, ok := r.Context().Value(ClaimsContextKey).(jwt.MapClaims)
|
||||
if !ok {
|
||||
http.Error(w, "Could not get user ID from context", http.StatusInternalServerError)
|
||||
http.Error(w, "Could not get claims from context", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
userIDFloat, ok := claims["user_id"].(float64)
|
||||
if !ok {
|
||||
http.Error(w, "Invalid user_id in token", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
userID := int(userIDFloat)
|
||||
|
||||
r.ParseMultipartForm(256 << 10) // 256KB
|
||||
|
||||
|
||||
Reference in New Issue
Block a user