kra/internal/server/handler/system/sys_jwt.go

28 lines
528 B
Go

package system
import (
"kra/pkg/response"
"kra/pkg/utils"
"github.com/gin-gonic/gin"
)
type JwtApi struct{}
// JsonInBlacklist JWT加入黑名单
func (j *JwtApi) JsonInBlacklist(c *gin.Context) {
token := utils.GetToken(c)
if token == "" {
response.FailWithMessage("token不存在", c)
return
}
if err := jwtBlacklistUsecase.JsonInBlacklist(c, token); err != nil {
response.FailWithMessage("jwt作废失败: "+err.Error(), c)
return
}
utils.ClearToken(c)
response.OkWithMessage("jwt作废成功", c)
}