Files
komari/api/admin/sessions.go
T
Akizon77 bd82d85431 fix: Docker 构建优化
feat: Github Actions
feat: 部分测试单元
style: 迁移akizon77到komari-monitor组织
2025-04-28 13:20:17 +08:00

47 lines
840 B
Go

package admin
import (
"github.com/komari-monitor/komari/database/accounts"
"github.com/gin-gonic/gin"
)
func GetSessions(c *gin.Context) {
ss, err := accounts.GetAllSessions()
if err != nil {
c.JSON(500, gin.H{
"status": "error",
"error": "Failed to get sessions",
})
return
}
c.JSON(200, ss)
}
func DeleteSession(c *gin.Context) {
var req struct {
Session string `json:"session" binding:"required"`
}
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(400, gin.H{
"status": "error",
"error": "Invalid or missing session",
})
return
}
err := accounts.DeleteSession(req.Session)
if err != nil {
c.JSON(500, gin.H{
"status": "error",
"error": "Failed to delete session",
})
return
}
c.JSON(200, gin.H{
"status": "success",
"message": "Session deleted successfully",
})
}