mirror of
https://github.com/Li4n0/revsuit.git
synced 2026-09-21 22:30:46 +08:00
fix(server): fix auth failure when complex characters in token (#42)
Co-authored-by: E99p1ant <[email protected]> Co-authored-by: Li4n0 <[email protected]>
This commit is contained in:
@@ -31,8 +31,11 @@ func (revsuit *Revsuit) registerPlatformRouter() {
|
||||
// /api need Authorization
|
||||
api := revsuit.http.Router.Group(revsuit.config.AdminPathPrefix + "/api")
|
||||
api.Use(func(c *gin.Context) {
|
||||
cookieToken, err := c.Request.Cookie("token")
|
||||
if !(c.Request.Header.Get("Token") == revsuit.http.Token || err == nil && cookieToken.Value == revsuit.http.Token) {
|
||||
token, err := c.Cookie("token")
|
||||
if err == http.ErrNoCookie {
|
||||
token = c.Request.Header.Get("Token")
|
||||
}
|
||||
if token != revsuit.http.Token {
|
||||
c.Abort()
|
||||
c.Status(403)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user