🎨双token校验

This commit is contained in:
coward
2024-07-12 10:11:37 +08:00
parent fb97082c0c
commit d74d7c579f
4 changed files with 58 additions and 5 deletions

View File

@@ -72,13 +72,14 @@ func (LoginApi) Login(c *gin.Context) {
}
// 生成token
token, expireAt, err := component.JWT().GenerateToken(user.Id)
token, expireAt, err := component.JWT().GenerateToken(user.Id, utils.Hash().SHA256(p.Password))
if err != nil {
log.Errorf("用户[%s]生成token失败: %v", user.Account, err.Error())
response.R(c).FailedWithError("登陆失败!")
return
}
c.Writer.Header().Set("X-TOKEN", utils.Hash().SHA256(p.Password))
response.R(c).OkWithData(map[string]any{
"token": token,
"type": "Bearer",