fix: 超管账号跳过强制改密码
This commit is contained in:
@@ -75,11 +75,18 @@ func (s AccountController) Login(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 强制改密码
|
data := map[string]any{}
|
||||||
forcePasswdChange, err := s.accountService.PasswordExpireTime(loginUser.User.LoginCount, loginUser.User.PasswordUpdateTime)
|
|
||||||
if err != nil {
|
if !config.IsSystemUser(loginUser.UserId) {
|
||||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, err.Error())))
|
// 强制改密码
|
||||||
return
|
forcePasswdChange, err := s.accountService.PasswordExpireTime(loginUser.User.LoginCount, loginUser.User.PasswordUpdateTime)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(200, resp.ErrMsg(i18n.TKey(language, err.Error())))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if forcePasswdChange {
|
||||||
|
data["forcePasswdChange"] = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成令牌,创建系统访问记录
|
// 生成令牌,创建系统访问记录
|
||||||
@@ -96,15 +103,10 @@ func (s AccountController) Login(c *gin.Context) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
data := map[string]any{
|
data["accessToken"] = tokenStr
|
||||||
"accessToken": tokenStr,
|
data["tokenType"] = strings.TrimRight(constants.HEADER_PREFIX, " ")
|
||||||
"tokenType": strings.TrimRight(constants.HEADER_PREFIX, " "),
|
data["expiresIn"] = (loginUser.ExpireTime - loginUser.LoginTime) / 1000
|
||||||
"expiresIn": (loginUser.ExpireTime - loginUser.LoginTime) / 1000,
|
data["userId"] = loginUser.UserId
|
||||||
"userId": loginUser.UserId,
|
|
||||||
}
|
|
||||||
if forcePasswdChange {
|
|
||||||
data["forcePasswdChange"] = true
|
|
||||||
}
|
|
||||||
c.JSON(200, resp.OkData(data))
|
c.JSON(200, resp.OkData(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,10 +147,12 @@ func (s AccountController) Me(c *gin.Context) {
|
|||||||
"permissions": perms,
|
"permissions": perms,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 强制改密码
|
if !isSystemUser {
|
||||||
forcePasswdChange, _ := s.accountService.PasswordExpireTime(info.User.LoginCount, info.User.PasswordUpdateTime)
|
// 强制改密码
|
||||||
if forcePasswdChange {
|
forcePasswdChange, _ := s.accountService.PasswordExpireTime(info.User.LoginCount, info.User.PasswordUpdateTime)
|
||||||
data["forcePasswdChange"] = true
|
if forcePasswdChange {
|
||||||
|
data["forcePasswdChange"] = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
c.JSON(200, resp.OkData(data))
|
c.JSON(200, resp.OkData(data))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user