diff --git a/src/modules/auth/controller/account.go b/src/modules/auth/controller/account.go index b8e1989d..edb81d1a 100644 --- a/src/modules/auth/controller/account.go +++ b/src/modules/auth/controller/account.go @@ -75,11 +75,18 @@ func (s AccountController) Login(c *gin.Context) { 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 + data := map[string]any{} + + if !config.IsSystemUser(loginUser.UserId) { + // 强制改密码 + 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{ - "accessToken": tokenStr, - "tokenType": strings.TrimRight(constants.HEADER_PREFIX, " "), - "expiresIn": (loginUser.ExpireTime - loginUser.LoginTime) / 1000, - "userId": loginUser.UserId, - } - if forcePasswdChange { - data["forcePasswdChange"] = true - } + data["accessToken"] = tokenStr + data["tokenType"] = strings.TrimRight(constants.HEADER_PREFIX, " ") + data["expiresIn"] = (loginUser.ExpireTime - loginUser.LoginTime) / 1000 + data["userId"] = loginUser.UserId c.JSON(200, resp.OkData(data)) } @@ -145,10 +147,12 @@ func (s AccountController) Me(c *gin.Context) { "permissions": perms, } - // 强制改密码 - forcePasswdChange, _ := s.accountService.PasswordExpireTime(info.User.LoginCount, info.User.PasswordUpdateTime) - if forcePasswdChange { - data["forcePasswdChange"] = true + if !isSystemUser { + // 强制改密码 + forcePasswdChange, _ := s.accountService.PasswordExpireTime(info.User.LoginCount, info.User.PasswordUpdateTime) + if forcePasswdChange { + data["forcePasswdChange"] = true + } } c.JSON(200, resp.OkData(data)) }