diff --git a/backend/cmd/main.go b/backend/cmd/main.go index 1e3c530..688e8d4 100644 --- a/backend/cmd/main.go +++ b/backend/cmd/main.go @@ -38,7 +38,6 @@ func main() { r.Group(func(r chi.Router) { r.Use(middleware.JWTAuth) r.Get("/api/user", api.GetUser) - r.Post("/api/user/deposit", api.Deposit) r.Get("/api/leaderboard", api.GetLeaderboard) r.Post("/api/roulette", api.PlaceBet) }) diff --git a/backend/pkg/api/handlers.go b/backend/pkg/api/handlers.go index 622efde..7e0c5e0 100644 --- a/backend/pkg/api/handlers.go +++ b/backend/pkg/api/handlers.go @@ -29,10 +29,6 @@ type RegisterRequest struct { Avatar string `json:"avatar,omitempty"` } -type DepositRequest struct { - Amount int `json:"amount"` -} - type BetRequest struct { BetAmount int `json:"bet_amount"` BetType string `json:"bet_type"` @@ -146,48 +142,6 @@ func Register(w http.ResponseWriter, r *http.Request) { }) } -func Deposit(w http.ResponseWriter, r *http.Request) { - username, ok := r.Context().Value(middleware.UsernameKey).(string) - if !ok || username == "" { - http.Error(w, "Unauthenticated user", http.StatusUnauthorized) - return - } - - var deposit DepositRequest - err := json.NewDecoder(r.Body).Decode(&deposit) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - if deposit.Amount <= 0 { - http.Error(w, "Invalid deposit amount", http.StatusBadRequest) - return - } - - var user models.User - err = db.DB.Where("username = ?", username).First(&user).Error - if err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - http.Error(w, "User not found", http.StatusNotFound) - return - } else { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - } else { - user.Balance += deposit.Amount - if err := db.DB.Save(&user).Error; err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - } - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusCreated) - json.NewEncoder(w).Encode(user) -} - func PlaceBet(w http.ResponseWriter, r *http.Request) { username, ok := r.Context().Value(middleware.UsernameKey).(string) if !ok || username == "" { diff --git a/frontend/profile.html b/frontend/profile.html index f5ed5df..14d6ebb 100644 --- a/frontend/profile.html +++ b/frontend/profile.html @@ -53,7 +53,8 @@
Username
+Username
+