From cb9560e1098e9a306e12bd097a6aa74a5b28539d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Dvo=C5=99=C3=A1k?= <150935816+Dvorinka@users.noreply.github.com> Date: Mon, 26 May 2025 12:33:55 +0200 Subject: [PATCH] Delete admin directory --- admin/account.go | 415 --------------------------- admin/admin.go | 733 ----------------------------------------------- 2 files changed, 1148 deletions(-) delete mode 100644 admin/account.go delete mode 100644 admin/admin.go diff --git a/admin/account.go b/admin/account.go deleted file mode 100644 index c90beb9..0000000 --- a/admin/account.go +++ /dev/null @@ -1,415 +0,0 @@ -package admin - -import ( - "crypto/rand" - "encoding/base64" - "encoding/json" - "net/http" - "time" -) - -type User struct { - Username string `json:"username"` - Password string `json:"password"` - Role string `json:"role"` -} - -type Session struct { - Token string - Username string - Role string - ExpiresAt time.Time -} - -type LoginRequest struct { - Username string `json:"username"` - Password string `json:"password"` -} - -type LoginResponse struct { - Success bool `json:"success"` - Message string `json:"message"` - Token string `json:"token,omitempty"` - Role string `json:"role,omitempty"` -} - -// In-memory storage (replace with database in production) -var ( - users = map[string]User{ - "admin": { - Username: "admin", - Password: "admin123", // In production, use hashed passwords - Role: "admin", - }, - } - sessions = make(map[string]Session) -) - -func generateToken() (string, error) { - bytes := make([]byte, 32) - if _, err := rand.Read(bytes); err != nil { - return "", err - } - return base64.URLEncoding.EncodeToString(bytes), nil -} - -func HandleLogin(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - - if r.Method == "GET" { - // Serve login page - tmpl := ` - -
- - -Administrátorské rozhraní
-