feat: 配置控制首次登录密码修改

This commit is contained in:
TsMask
2025-04-18 17:09:30 +08:00
parent b708c8924b
commit e30069603d
6 changed files with 19 additions and 12 deletions

View File

@@ -145,10 +145,15 @@ func (s Account) passwordRetryCount(userName string) (string, int64, time.Durati
return retryKey, retryCountInt64, time.Duration(lockTime) * time.Minute, nil
}
// passwordRetryCount 密码过期时间
func (s Account) PasswordExpireTime(loginCount, passwordUpdateTime int64) (bool, error) {
// 首次登录
forcePasswdChange := loginCount < 1
// PasswordCountOrExpireTime 首次登录或密码过期时间
func (s Account) PasswordCountOrExpireTime(loginCount, passwordUpdateTime int64) (bool, error) {
forcePasswdChange := false
// 从数据库配置获取-首次登录密码修改
fristPasswdChangeStr := s.sysConfigService.FindValueByKey("sys.user.fristPasswdChange")
if parse.Boolean(fristPasswdChangeStr) {
forcePasswdChange = loginCount < 1 || passwordUpdateTime == 0
}
// 非首次登录,判断密码是否过期
if !forcePasswdChange {
alert, err := s.sysUserService.ValidatePasswordExpireTime(passwordUpdateTime)
@@ -157,7 +162,6 @@ func (s Account) PasswordExpireTime(loginCount, passwordUpdateTime int64) (bool,
}
forcePasswdChange = alert
}
return forcePasswdChange, nil
}