feat(admin): added admin panel

This commit is contained in:
2025-06-18 17:29:01 +03:00
parent a157fc1cc3
commit 2c682c5123
5 changed files with 119 additions and 16 deletions

View File

@@ -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