mirror of
https://github.com/flipped-aurora/gin-vue-admin.git
synced 2026-10-17 06:55:34 +00:00
32 lines
1.0 KiB
Go
32 lines
1.0 KiB
Go
package system
|
|
|
|
import (
|
|
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
|
"github.com/gin-gonic/gin"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
type JwtApi struct{}
|
|
|
|
// JsonInBlacklist
|
|
// @Tags Jwt
|
|
// @Summary jwt加入黑名单
|
|
// @Security ApiKeyAuth
|
|
// @accept application/json
|
|
// @Produce application/json
|
|
// @Success 200 {object} response.Response{msg=string} "jwt加入黑名单"
|
|
// @Router /jwt/jsonInBlacklist [post]
|
|
func (j *JwtApi) JsonInBlacklist(c *gin.Context) {
|
|
token := c.Request.Header.Get("x-token")
|
|
jwt := system.JwtBlacklist{Jwt: token}
|
|
err := jwtService.JsonInBlacklist(jwt)
|
|
if err != nil {
|
|
global.GVA_LOG.Error(global.Translate("sys_user.jwtInvalidationFailed"), zap.Error(err))
|
|
response.FailWithMessage(global.Translate("sys_jwt_blacklist.jwtInvalidationFailedErr"), c)
|
|
return
|
|
}
|
|
response.OkWithMessage(global.Translate("sys_jwt_blacklist.jwtInvalidatedSuccess"), c)
|
|
}
|