aboutsummaryrefslogtreecommitdiff
path: root/weed/admin/dash/handler_auth.go
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2025-07-02 00:04:46 -0700
committerchrislu <chris.lu@gmail.com>2025-07-02 00:04:46 -0700
commit6b706f9ccdf46046133c867c4240c4e8594da5b3 (patch)
treecc57ff507de3f355ea6fab2175fb920a0120ae98 /weed/admin/dash/handler_auth.go
parentf47c4aef5a104a8c6ccd011ce441c453c4bebe62 (diff)
downloadseaweedfs-6b706f9ccdf46046133c867c4240c4e8594da5b3.tar.xz
seaweedfs-6b706f9ccdf46046133c867c4240c4e8594da5b3.zip
rename files
*_server.go - main server files *_management.go - business logic *_data.go - data structures and types *_middleware.go - middleware logic
Diffstat (limited to 'weed/admin/dash/handler_auth.go')
-rw-r--r--weed/admin/dash/handler_auth.go53
1 files changed, 0 insertions, 53 deletions
diff --git a/weed/admin/dash/handler_auth.go b/weed/admin/dash/handler_auth.go
deleted file mode 100644
index 986a30290..000000000
--- a/weed/admin/dash/handler_auth.go
+++ /dev/null
@@ -1,53 +0,0 @@
-package dash
-
-import (
- "net/http"
-
- "github.com/gin-contrib/sessions"
- "github.com/gin-gonic/gin"
-)
-
-// ShowLogin displays the login page
-func (s *AdminServer) ShowLogin(c *gin.Context) {
- // If authentication is not required, redirect to admin
- session := sessions.Default(c)
- if session.Get("authenticated") == true {
- c.Redirect(http.StatusSeeOther, "/admin")
- return
- }
-
- // For now, return a simple login form as JSON
- c.HTML(http.StatusOK, "login.html", gin.H{
- "title": "SeaweedFS Admin Login",
- "error": c.Query("error"),
- })
-}
-
-// HandleLogin handles login form submission
-func (s *AdminServer) HandleLogin(username, password string) gin.HandlerFunc {
- return func(c *gin.Context) {
- loginUsername := c.PostForm("username")
- loginPassword := c.PostForm("password")
-
- if loginUsername == username && loginPassword == password {
- session := sessions.Default(c)
- session.Set("authenticated", true)
- session.Set("username", loginUsername)
- session.Save()
-
- c.Redirect(http.StatusSeeOther, "/admin")
- return
- }
-
- // Authentication failed
- c.Redirect(http.StatusSeeOther, "/login?error=Invalid credentials")
- }
-}
-
-// HandleLogout handles user logout
-func (s *AdminServer) HandleLogout(c *gin.Context) {
- session := sessions.Default(c)
- session.Clear()
- session.Save()
- c.Redirect(http.StatusSeeOther, "/login")
-}