|
|
@ -1,9 +1,6 @@ |
|
|
|
package system |
|
|
|
|
|
|
|
import ( |
|
|
|
"strconv" |
|
|
|
"time" |
|
|
|
|
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/global" |
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request" |
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" |
|
|
@ -11,8 +8,8 @@ import ( |
|
|
|
systemReq "github.com/flipped-aurora/gin-vue-admin/server/model/system/request" |
|
|
|
systemRes "github.com/flipped-aurora/gin-vue-admin/server/model/system/response" |
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/utils" |
|
|
|
"strconv" |
|
|
|
|
|
|
|
"github.com/dgrijalva/jwt-go" |
|
|
|
"github.com/gin-gonic/gin" |
|
|
|
"github.com/go-redis/redis/v8" |
|
|
|
"go.uber.org/zap" |
|
|
@ -47,19 +44,13 @@ func (b *BaseApi) Login(c *gin.Context) { |
|
|
|
// 登录以后签发jwt
|
|
|
|
func (b *BaseApi) tokenNext(c *gin.Context, user system.SysUser) { |
|
|
|
j := &utils.JWT{SigningKey: []byte(global.GVA_CONFIG.JWT.SigningKey)} // 唯一签名
|
|
|
|
claims := systemReq.CustomClaims{ |
|
|
|
claims := j.CreateClaims(systemReq.BaseClaims{ |
|
|
|
UUID: user.UUID, |
|
|
|
ID: user.ID, |
|
|
|
NickName: user.NickName, |
|
|
|
Username: user.Username, |
|
|
|
AuthorityId: user.AuthorityId, |
|
|
|
BufferTime: global.GVA_CONFIG.JWT.BufferTime, // 缓冲时间1天 缓冲时间内会获得新的token刷新令牌 此时一个用户会存在两个有效令牌 但是前端只留一个 另一个会丢失
|
|
|
|
StandardClaims: jwt.StandardClaims{ |
|
|
|
NotBefore: time.Now().Unix() - 1000, // 签名生效时间
|
|
|
|
ExpiresAt: time.Now().Unix() + global.GVA_CONFIG.JWT.ExpiresTime, // 过期时间 7天 配置文件
|
|
|
|
Issuer: "qmPlus", // 签名的发行者
|
|
|
|
}, |
|
|
|
} |
|
|
|
}) |
|
|
|
token, err := j.CreateToken(claims) |
|
|
|
if err != nil { |
|
|
|
global.GVA_LOG.Error("获取token失败!", zap.Any("err", err)) |
|
|
|