feat: add compatible Trojan manager image

This commit is contained in:
chermack
2026-07-26 05:01:15 +08:00
parent 059be96536
commit cb17d56cae
26 changed files with 320 additions and 41 deletions
+10 -1
View File
@@ -123,6 +123,12 @@ func RequestUsername(c *gin.Context) string {
return claims[identityKey].(string)
}
func RequireAdmin(c *gin.Context) bool {
if RequestUsername(c) == "admin" { return true }
c.JSON(403, gin.H{"code": 403, "message": "administrator access required"})
return false
}
// Auth 权限router
func Auth(r *gin.Engine, timeout int) *jwt.GinJWTMiddleware {
jwtInit(timeout)
@@ -152,7 +158,10 @@ func Auth(r *gin.Engine, timeout int) *jwt.GinJWTMiddleware {
}
})
r.POST("/auth/login", authMiddleware.LoginHandler)
r.POST("/auth/register", updateUser)
r.POST("/auth/register", func(c *gin.Context) {
if result, _ := core.GetValue("admin_pass"); result != "" { c.JSON(403, gin.H{"code":403,"message":"administrator already initialized"}); return }
updateUser(c)
})
authO := r.Group("/auth")
authO.Use(authMiddleware.MiddlewareFunc())
{