Skip to content

Commit

Permalink
添加修改登录页信息接口
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrohy committed Mar 16, 2020
1 parent b63d994 commit c66f225
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
7 changes: 6 additions & 1 deletion web/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ func Auth(r *gin.Engine) *jwt.GinJWTMiddleware {
if result == "" {
c.JSON(201, gin.H{"code": 201, "message": "No administrator account found inside the database"})
} else {
c.JSON(200, gin.H{"code": 200, "message": "administrator is ok!"})
title, err := core.GetValue("login_title")
if err != nil {
c.JSON(200, gin.H{"title": "trojan 管理平台"})
} else {
c.JSON(200, gin.H{"title": title})
}
}
})
r.POST("/auth/login", authMiddleware.LoginHandler)
Expand Down
12 changes: 12 additions & 0 deletions web/controller/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controller

import (
"time"
"trojan/core"
"trojan/trojan"
)

Expand Down Expand Up @@ -31,3 +32,14 @@ func Version() *ResponseBody {
}
return &responseBody
}

// SetLoginInfo 设置登录页信息
func SetLoginInfo(title string) *ResponseBody {
responseBody := ResponseBody{Msg: "success"}
defer TimeCost(time.Now(), &responseBody)
err := core.SetValue("login_title", title)
if err != nil {
responseBody.Msg = err.Error()
}
return &responseBody
}
3 changes: 3 additions & 0 deletions web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ func commonRouter(router *gin.Engine) {
common.GET("/version", func(c *gin.Context) {
c.JSON(200, controller.Version())
})
common.POST("/loginInfo", func(c *gin.Context) {
c.JSON(200, controller.SetLoginInfo(c.PostForm("title")))
})
}
}

Expand Down

0 comments on commit c66f225

Please sign in to comment.