feat: update
This commit is contained in:
@@ -3,6 +3,7 @@ package middlewares
|
||||
import (
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"quyun/app/models"
|
||||
"quyun/pkg/utils"
|
||||
@@ -70,6 +71,17 @@ func (f *Middlewares) Auth(ctx fiber.Ctx) error {
|
||||
}
|
||||
return ctx.Redirect().To(fullUrl)
|
||||
}
|
||||
|
||||
// TOKEN 过期
|
||||
if user.AuthToken.Data.ExpiresAt.Before(time.Now()) {
|
||||
// remove cookie
|
||||
ctx.ClearCookie("token")
|
||||
if ctx.XHR() {
|
||||
return ctx.SendStatus(fiber.StatusUnauthorized)
|
||||
}
|
||||
return ctx.Redirect().To(fullUrl)
|
||||
}
|
||||
|
||||
ctx.Locals("user", user)
|
||||
|
||||
return ctx.Next()
|
||||
|
||||
Reference in New Issue
Block a user