mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-19 21:42:24 +00:00
Fix ident
This commit is contained in:
parent
d1aa040d7c
commit
254e5a6761
3 changed files with 19 additions and 19 deletions
|
@ -21,10 +21,10 @@ func NewAPIController(g *gin.RouterGroup) *APIController {
|
|||
}
|
||||
|
||||
func (controller *APIController) initRouter(router *gin.RouterGroup) {
|
||||
apiV1 := router.Group("/panel/api")
|
||||
apiV1.Use(controller.checkLogin)
|
||||
apiV1 := router.Group("/panel/api")
|
||||
apiV1.Use(controller.checkLogin)
|
||||
|
||||
inboundsApiGroup := apiV1.Group("/inbounds")
|
||||
inboundsApiGroup := apiV1.Group("/inbounds")
|
||||
controller.inbounds = NewInboundController(inboundsApiGroup)
|
||||
|
||||
inboundRoutes := []struct {
|
||||
|
@ -69,8 +69,8 @@ func (controller *APIController) initApiV2Router(router *gin.RouterGroup) {
|
|||
serverApiGroup := apiV2.Group("/server")
|
||||
inboundsApiGroup := apiV2.Group("/inbounds")
|
||||
|
||||
controller.inbounds = NewInboundController(inboundsApiGroup)
|
||||
controller.server = NewServerController(serverApiGroup)
|
||||
controller.inbounds = NewInboundController(inboundsApiGroup)
|
||||
controller.server = NewServerController(serverApiGroup)
|
||||
|
||||
/**
|
||||
* Inbounds
|
||||
|
|
|
@ -42,14 +42,14 @@ func I18nWeb(c *gin.Context, name string, params ...string) string {
|
|||
}
|
||||
|
||||
func (a *BaseController) apiTokenGuard(c *gin.Context) {
|
||||
bearerToken := c.Request.Header.Get("Authorization")
|
||||
tokenParts := strings.Split(bearerToken, " ")
|
||||
if len(tokenParts) != 2 {
|
||||
bearerToken := c.Request.Header.Get("Authorization")
|
||||
tokenParts := strings.Split(bearerToken, " ")
|
||||
if len(tokenParts) != 2 {
|
||||
pureJsonMsg(c, http.StatusUnauthorized, false, "Invalid token format")
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
reqToken := tokenParts[1]
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
reqToken := tokenParts[1]
|
||||
token, err := a.settingService.GetApiToken()
|
||||
|
||||
if err != nil {
|
||||
|
@ -59,7 +59,7 @@ func (a *BaseController) apiTokenGuard(c *gin.Context) {
|
|||
}
|
||||
|
||||
if reqToken != token {
|
||||
pureJsonMsg(c, http.StatusUnauthorized, false, "Auth failed")
|
||||
pureJsonMsg(c, http.StatusUnauthorized, false, "Auth failed")
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ func (a *BaseController) apiTokenGuard(c *gin.Context) {
|
|||
|
||||
session.SetSessionUser(c, user)
|
||||
|
||||
c.Next()
|
||||
c.Next()
|
||||
|
||||
session.ClearSession(c)
|
||||
}
|
|
@ -150,20 +150,20 @@ func (a *SettingController) getDefaultXrayConfig(c *gin.Context) {
|
|||
}
|
||||
|
||||
func (a *SettingController) getApiToken(c *gin.Context) {
|
||||
response := &ApiTokenResponse{}
|
||||
response := &ApiTokenResponse{}
|
||||
token, err := a.settingService.GetApiToken()
|
||||
if err != nil {
|
||||
jsonObj(c, response , err)
|
||||
return
|
||||
jsonObj(c, response , err)
|
||||
return
|
||||
}
|
||||
|
||||
response.Token = token
|
||||
|
||||
jsonObj(c, response , nil)
|
||||
jsonObj(c, response , nil)
|
||||
}
|
||||
|
||||
func (a *SettingController) generateApiToken(c *gin.Context) {
|
||||
response := &ApiTokenResponse{}
|
||||
response := &ApiTokenResponse{}
|
||||
randomBytes := make([]byte, 32)
|
||||
|
||||
_, err := rand.Read(randomBytes)
|
||||
|
|
Loading…
Reference in a new issue