Accepts token in querystring

This commit is contained in:
2024-06-22 20:28:58 +08:00
parent d654931483
commit 4537bc9f28
3 changed files with 13 additions and 7 deletions

View File

@ -20,10 +20,14 @@ func (v *HyperConn) AuthMiddleware(c *fiber.Ctx) error {
tk := strings.Replace(header, "Bearer", "", 1)
atk = strings.TrimSpace(tk)
}
if tk := c.Query("tk"); len(tk) > 0 {
atk = strings.TrimSpace(tk)
}
c.Locals("p_token", atk)
if user, newAtk, newRtk, err := v.DoAuthenticate(atk, c.Cookies(CookieRtk)); err == nil {
rtk := c.Cookies(CookieRtk)
if user, newAtk, newRtk, err := v.DoAuthenticate(atk, rtk); err == nil {
if newAtk != atk {
c.Cookie(&fiber.Cookie{
Name: CookieAtk,

View File

@ -18,6 +18,9 @@ func AuthMiddleware(c *fiber.Ctx) error {
tk := strings.Replace(header, "Bearer", "", 1)
atk = strings.TrimSpace(tk)
}
if tk := c.Query("tk"); len(tk) > 0 {
atk = strings.TrimSpace(tk)
}
c.Locals("p_token", atk)