合并分支

This commit is contained in:
2023-08-04 17:11:10 +08:00
parent 12ec8d26bf
commit 020e76b901
100 changed files with 12692 additions and 2574 deletions

View File

@@ -14,8 +14,12 @@ import (
// ! 仅通过该中间件是不能保证上下文中一定保存有用户会话信息的。
func SessionRecovery(c *fiber.Ctx) error {
if auth := c.Get("Authorization", ""); len(auth) > 0 {
token := strings.Fields(auth)[1]
session, err := cache.RetreiveSession(token)
authFields := strings.Fields(auth)
if len(authFields) != 2 || strings.ToLower(authFields[0]) != "bearer" || len(authFields[1]) == 0 {
return c.Next()
}
token := authFields[1]
session, err := cache.RetrieveSession(token)
if err == nil && session != nil {
c.Locals("session", session)