From 14142be38f62ca834db6e8723321b85386a8887b Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Tue, 5 Dec 2023 10:46:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E9=83=A8=E5=88=86?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E6=A0=A1=E9=AA=8C=20(#3181)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #3174 --- backend/app/service/device.go | 5 ++++ backend/app/service/fail2ban.go | 2 +- backend/constant/errs.go | 4 ++++ backend/i18n/lang/en.yaml | 5 +++- backend/i18n/lang/zh-Hant.yaml | 5 +++- backend/i18n/lang/zh.yaml | 3 +++ frontend/src/lang/modules/en.ts | 8 +++---- frontend/src/lang/modules/tw.ts | 8 +++---- frontend/src/lang/modules/zh.ts | 8 +++---- .../src/views/setting/panel/name/index.vue | 2 +- .../views/setting/panel/username/index.vue | 4 ++-- .../toolbox/fail2ban/max-retry/index.vue | 23 ++++++++++++------- 12 files changed, 51 insertions(+), 26 deletions(-) diff --git a/backend/app/service/device.go b/backend/app/service/device.go index 60dd54230..acf891f75 100644 --- a/backend/app/service/device.go +++ b/backend/app/service/device.go @@ -12,6 +12,8 @@ import ( "time" "github.com/1Panel-dev/1Panel/backend/app/dto" + "github.com/1Panel-dev/1Panel/backend/buserr" + "github.com/1Panel-dev/1Panel/backend/constant" "github.com/1Panel-dev/1Panel/backend/global" "github.com/1Panel-dev/1Panel/backend/utils/cmd" "github.com/1Panel-dev/1Panel/backend/utils/common" @@ -189,6 +191,9 @@ func (u *DeviceService) UpdateHosts(req []dto.HostHelper) error { func (u *DeviceService) UpdatePasswd(req dto.ChangePasswd) error { std, err := cmd.Execf("%s echo '%s:%s' | %s chpasswd", cmd.SudoHandleCmd(), req.User, req.Passwd, cmd.SudoHandleCmd()) if err != nil { + if strings.Contains(err.Error(), "does not exist") { + return buserr.New(constant.ErrNotExistUser) + } return errors.New(std) } return nil diff --git a/backend/app/service/fail2ban.go b/backend/app/service/fail2ban.go index 729925209..7741e5a1d 100644 --- a/backend/app/service/fail2ban.go +++ b/backend/app/service/fail2ban.go @@ -35,7 +35,7 @@ func (u *Fail2BanService) LoadBaseInfo() (dto.Fail2BanBaseInfo, error) { return baseInfo, err } baseInfo.IsEnable, baseInfo.IsActive, baseInfo.IsExist = client.Status() - if !baseInfo.IsExist { + if !baseInfo.IsActive { baseInfo.Version = "-" return baseInfo, nil } diff --git a/backend/constant/errs.go b/backend/constant/errs.go index 2bd1313f0..f648a0a50 100644 --- a/backend/constant/errs.go +++ b/backend/constant/errs.go @@ -144,3 +144,7 @@ var ( var ( ErrBashExecute = "ErrBashExecute" ) + +var ( + ErrNotExistUser = "ErrNotExistUser" +) diff --git a/backend/i18n/lang/en.yaml b/backend/i18n/lang/en.yaml index 55540329d..0eb441561 100644 --- a/backend/i18n/lang/en.yaml +++ b/backend/i18n/lang/en.yaml @@ -155,4 +155,7 @@ ErrUserFindErr: "Failed to find user {{ .name }} {{ .err }}" ErrFirewall: "No firewalld or ufw service is detected. Please check and try again!" #cronjob -ErrBashExecute: "Script execution error, please check the specific information in the task output text area." \ No newline at end of file +ErrBashExecute: "Script execution error, please check the specific information in the task output text area." + +#toolbox +ErrNotExistUser: "The current user does not exist. Please modify and retry!" diff --git a/backend/i18n/lang/zh-Hant.yaml b/backend/i18n/lang/zh-Hant.yaml index ea8eb6f2d..6b50167a5 100644 --- a/backend/i18n/lang/zh-Hant.yaml +++ b/backend/i18n/lang/zh-Hant.yaml @@ -156,4 +156,7 @@ ErrUserFindErr: "用戶 {{ .name }} 查找失敗 {{ .err }}" ErrFirewall: "當前未檢測到系統 firewalld 或 ufw 服務,請檢查後重試!" #cronjob -ErrBashExecute: "腳本執行錯誤,請在任務輸出文本域中查看具體信息。" \ No newline at end of file +ErrBashExecute: "腳本執行錯誤,請在任務輸出文本域中查看具體信息。" + +#toolbox +ErrNotExistUser: "當前使用者不存在,請修改後重試!" diff --git a/backend/i18n/lang/zh.yaml b/backend/i18n/lang/zh.yaml index a93cbf2c8..ba9bdb4e2 100644 --- a/backend/i18n/lang/zh.yaml +++ b/backend/i18n/lang/zh.yaml @@ -156,3 +156,6 @@ ErrFirewall: "当前未检测到系统 firewalld 或 ufw 服务,请检查后 #cronjob ErrBashExecute: "脚本执行错误,请在任务输出文本域中查看具体信息。" + +#toolbox +ErrNotExistUser: "当前用户不存在,请修改后重试!" \ No newline at end of file diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 4fee8fba0..c32049998 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -1153,10 +1153,10 @@ const message = { setting: { all: 'All', panel: 'Panel', - userChange: 'Change username', - userChangeHelper: 'Change the user name to log out. Do you want to continue?', - user: 'User Name', - passwd: 'Password', + user: 'Panel User', + userChange: 'Change Panel User', + userChangeHelper: 'Changing the panel user will log you out. Continue?', + passwd: 'Panel Password', emailHelper: 'For password retrieval', title: 'Panel Alias', panelPort: 'Panel Port', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index b1920891d..d87d20dca 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -1097,10 +1097,10 @@ const message = { setting: { all: '全部', panel: '面板', - user: '用戶名稱', - userChange: '修改用戶名', - userChangeHelper: '修改用戶名將退出登陸,是否繼續?', - passwd: '用戶密碼', + user: '面板用户', + userChange: '修改面板用户', + userChangeHelper: '修改面板用户将退出登录,是否继续?', + passwd: '面板密码', emailHelper: '用於密碼找回', title: '面板別名', panelPort: '面板端口', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 8cab98514..92b8c0a12 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -1098,10 +1098,10 @@ const message = { setting: { all: '全部', panel: '面板', - user: '用户名称', - userChange: '修改用户名', - userChangeHelper: '修改用户名将退出登陆,是否继续?', - passwd: '用户密码', + user: '面板用户', + userChange: '修改面板用户', + userChangeHelper: '修改面板用户将退出登陆,是否继续?', + passwd: '面板密码', emailHelper: '用于密码找回', title: '面板别名', panelPort: '面板端口', diff --git a/frontend/src/views/setting/panel/name/index.vue b/frontend/src/views/setting/panel/name/index.vue index 7160b0bed..d11137b18 100644 --- a/frontend/src/views/setting/panel/name/index.vue +++ b/frontend/src/views/setting/panel/name/index.vue @@ -7,7 +7,7 @@ - + diff --git a/frontend/src/views/setting/panel/username/index.vue b/frontend/src/views/setting/panel/username/index.vue index 6a13a1ed1..86e9661d1 100644 --- a/frontend/src/views/setting/panel/username/index.vue +++ b/frontend/src/views/setting/panel/username/index.vue @@ -2,7 +2,7 @@
- + diff --git a/frontend/src/views/toolbox/fail2ban/max-retry/index.vue b/frontend/src/views/toolbox/fail2ban/max-retry/index.vue index 749c6af77..1654b80cc 100644 --- a/frontend/src/views/toolbox/fail2ban/max-retry/index.vue +++ b/frontend/src/views/toolbox/fail2ban/max-retry/index.vue @@ -4,15 +4,18 @@ - + - - + + @@ -35,7 +38,7 @@ import { reactive, ref } from 'vue'; import i18n from '@/lang'; import { MsgSuccess } from '@/utils/message'; import { FormInstance } from 'element-plus'; -import { Rules } from '@/global/form-rules'; +import { Rules, checkNumberRange } from '@/global/form-rules'; import DrawerHeader from '@/components/drawer-header/index.vue'; import { updateFail2ban } from '@/api/modules/toolbox'; @@ -51,6 +54,10 @@ const form = reactive({ maxRetry: 5, }); +const rules = reactive({ + maxRetry: [Rules.number, checkNumberRange(1, 99)], +}); + const formRef = ref(); const acceptParams = (params: DialogProps): void => {