优化结构
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"kra/internal/server/httpx"
|
||||
"kra/internal/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Session struct{ tokens *service.TokenService }
|
||||
|
||||
func NewSession(tokens *service.TokenService) *Session { return &Session{tokens: tokens} }
|
||||
func (h *Session) Logout(c *gin.Context) {
|
||||
token := c.GetHeader("x-token")
|
||||
if token == "" {
|
||||
token, _ = c.Cookie("x-token")
|
||||
}
|
||||
if err := h.tokens.BlacklistToken(c.Request.Context(), token); err != nil {
|
||||
httpx.Fail(c, "jwt作废失败")
|
||||
return
|
||||
}
|
||||
httpx.SetTokenCookie(c, "", -1)
|
||||
httpx.Write(c, httpx.CodeSuccess, gin.H{}, "jwt作废成功")
|
||||
}
|
||||
Reference in New Issue
Block a user