mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
bug fix
This commit is contained in:
parent
87c2fa520c
commit
855634cd45
10 changed files with 61 additions and 16 deletions
|
@ -51,12 +51,14 @@ func Login(c *gin.Context) {
|
|||
|
||||
func Logout(c *gin.Context) {
|
||||
token := c.GetHeader("Authorization")
|
||||
err := model.DeleteToken(token)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": err.Error(),
|
||||
})
|
||||
return
|
||||
if token != "" {
|
||||
err := model.DeleteToken(token)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
c.JSON(http.StatusNoContent, gin.H{})
|
||||
}
|
||||
|
|
4
server/app.example.ini
Normal file
4
server/app.example.ini
Normal file
|
@ -0,0 +1,4 @@
|
|||
[server]
|
||||
HttpPort = 9000
|
||||
RunMode = debug
|
||||
JwtSecret =
|
|
@ -1,5 +1,4 @@
|
|||
[server]
|
||||
HttpPort = 9000
|
||||
RunMode = debug
|
||||
WebSocketToken = f094ec2e-8455-48e1-a5c0-edabe1d79867
|
||||
JwtSecret = f094ec2e-8455-48e1-a5c0-edabe1d79867
|
||||
JwtSecret = F7AFBC0E-227E-40AC-918D-60122D725398
|
||||
|
|
|
@ -4,6 +4,7 @@ go 1.15
|
|||
|
||||
require (
|
||||
github.com/appleboy/gin-jwt/v2 v2.6.4
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||
github.com/dustin/go-humanize v1.0.0
|
||||
github.com/gin-gonic/gin v1.6.3
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"github.com/0xJacky/Nginx-UI/api"
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
"github.com/gin-gonic/gin"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
@ -23,11 +22,9 @@ func authRequired() gin.HandlerFunc {
|
|||
return
|
||||
}
|
||||
}
|
||||
log.Println(c.Query("token"))
|
||||
log.Println(token)
|
||||
|
||||
n := model.CheckToken(token)
|
||||
log.Println(n)
|
||||
|
||||
if n < 1 {
|
||||
c.JSON(http.StatusForbidden, gin.H{
|
||||
"message": "auth fail",
|
||||
|
@ -52,11 +49,10 @@ func InitRouter() *gin.Engine {
|
|||
})
|
||||
|
||||
r.POST("/login", api.Login)
|
||||
r.DELETE("/logout", api.Logout)
|
||||
|
||||
endpoint := r.Group("/", authRequired())
|
||||
{
|
||||
endpoint.DELETE("/logout", api.Logout)
|
||||
|
||||
endpoint.GET("domains", api.GetDomains)
|
||||
endpoint.GET("domain/:name", api.GetDomain)
|
||||
endpoint.POST("domain/:name", api.EditDomain)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue