Updated SessionIdCheck func to support POST and GET method

master
Alex 2021-08-01 22:08:30 +02:00
parent 81740c26fc
commit 009dcf6130
1 changed files with 12 additions and 2 deletions

View File

@ -86,20 +86,30 @@ func getUserSessionExpiresTime() time.Time {
}
func SessionIdCheck(c *fiber.Ctx) error {
sessionId := c.Cookies(cfg.Settings.Cookies.SessionId)
var sessionId string
log.Info("query", c.Method())
if c.Method() == "GET" {
log.Infoln("q", c.Query("session_id"))
sessionId = c.Query(cfg.Settings.Cookies.SessionId)
} else {
sessionId = c.Cookies(cfg.Settings.Cookies.SessionId)
}
log.Debugln("SessionIdCheck", sessionId)
if sessionId == "" {
return fiber.ErrUnauthorized
}
log.Infoln("sess", sessionId)
valid := isSessionIdValid(sessionId)
if valid {
return c.Next()
}
log.Info("unauth")
return fiber.ErrUnauthorized
}