1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-07-01 12:03:25 +00:00
This commit is contained in:
wdvxdr
2021-03-29 12:28:43 +08:00
parent db63cbec82
commit 32bba9994b

View File

@ -79,9 +79,10 @@ func (s *httpServer) Run(addr, authToken string, bot *coolq.CQBot) {
s.engine.Use(func(c *gin.Context) { s.engine.Use(func(c *gin.Context) {
auth := c.Request.Header.Get("Authorization") auth := c.Request.Header.Get("Authorization")
switch { switch {
case auth != "" && strings.SplitN(auth, " ", 2)[1] != authToken: case auth != "":
c.AbortWithStatus(401) if strings.SplitN(auth, " ", 2)[1] != authToken {
return c.AbortWithStatus(401)
}
case c.Query("access_token") != authToken: case c.Query("access_token") != authToken:
c.AbortWithStatus(401) c.AbortWithStatus(401)
return return