diff --git a/backend/src/main/java/io/dataease/auth/server/AuthServer.java b/backend/src/main/java/io/dataease/auth/server/AuthServer.java index 0f52b94437..cfc597bb1e 100644 --- a/backend/src/main/java/io/dataease/auth/server/AuthServer.java +++ b/backend/src/main/java/io/dataease/auth/server/AuthServer.java @@ -18,12 +18,14 @@ import io.dataease.commons.utils.ServletUtils; import io.dataease.plugins.xpack.display.dto.response.SysSettingDto; import io.dataease.plugins.xpack.display.service.DisPlayXpackService;*/ +import io.dataease.i18n.Translator; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; + import java.util.HashMap; import java.util.List; import java.util.Map; @@ -41,11 +43,11 @@ public class AuthServer implements AuthApi { String password = loginDto.getPassword(); SysUserEntity user = authUserService.getUserByName(username); - if (ObjectUtils.isEmpty(user)){ - throw new RuntimeException("没有该用户!"); + if (ObjectUtils.isEmpty(user)) { + throw new RuntimeException(Translator.get("i18n_id_or_pwd_error")); } - if (user.getEnabled()==0){ - throw new RuntimeException("用户已经失效!"); + if (user.getEnabled() == 0) { + throw new RuntimeException(Translator.get("i18n_id_or_pwd_error")); } String realPwd = user.getPassword(); //私钥解密 @@ -53,10 +55,10 @@ public class AuthServer implements AuthApi { //md5加密 pwd = CodingUtil.md5(pwd); - if (!StringUtils.equals(pwd, realPwd)){ - throw new RuntimeException("密码错误!"); + if (!StringUtils.equals(pwd, realPwd)) { + throw new RuntimeException(Translator.get("i18n_id_or_pwd_error")); } - Map result = new HashMap<>(); + Map result = new HashMap<>(); TokenInfo tokenInfo = TokenInfo.builder().userId(user.getUserId()).username(username).lastLoginTime(System.currentTimeMillis()).build(); String token = JWTUtils.sign(tokenInfo, realPwd); // 记录token操作时间 @@ -68,7 +70,7 @@ public class AuthServer implements AuthApi { @Override public CurrentUserDto userInfo() { - CurrentUserDto userDto = (CurrentUserDto)SecurityUtils.getSubject().getPrincipal(); + CurrentUserDto userDto = (CurrentUserDto) SecurityUtils.getSubject().getPrincipal(); if (ObjectUtils.isEmpty(userDto)) { String token = ServletUtils.getToken(); Long userId = JWTUtils.tokenInfoByToken(token).getUserId(); @@ -84,7 +86,7 @@ public class AuthServer implements AuthApi { } @Override - public String logout(){ + public String logout() { String token = ServletUtils.getToken(); Long userId = JWTUtils.tokenInfoByToken(token).getUserId(); authUserService.clearCache(userId); diff --git a/backend/src/main/java/io/dataease/controller/IndexController.java b/backend/src/main/java/io/dataease/controller/IndexController.java index 948dc5c2df..61b37b73ff 100644 --- a/backend/src/main/java/io/dataease/controller/IndexController.java +++ b/backend/src/main/java/io/dataease/controller/IndexController.java @@ -14,7 +14,7 @@ public class IndexController { return "index.html"; } - @GetMapping(value = "/login") + @GetMapping(value = "/llogin") public String login() { return "index.html"; } diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 9fe4ffeaed..92ff232206 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -246,4 +246,5 @@ i18n_sync_job_exists=There is already a synchronization task running, please try i18n_datasource_check_fail=Invalid,please check config i18n_not_find_user=Can not find user. i18n_sql_not_empty=SQL can not be empty. -i18n_task_name_repeat=Name is used in same data set \ No newline at end of file +i18n_task_name_repeat=Name is used in same data set +i18n_id_or_pwd_error=Invalid ID or password \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 8968ee429a..f4330b8a53 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -248,4 +248,5 @@ i18n_sync_job_exists=已经有同步任务在运行,稍后重试 i18n_datasource_check_fail=校验失败,请检查配置信息 i18n_not_find_user=未找到用户 i18n_sql_not_empty=SQL 不能为空 -i18n_task_name_repeat=同一数据集下任务名称已被使用 \ No newline at end of file +i18n_task_name_repeat=同一数据集下任务名称已被使用 +i18n_id_or_pwd_error=无效的ID或密码 \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 9b91c813dc..5537823911 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -248,4 +248,5 @@ i18n_sync_job_exists=已經有同步任務在運行,稍後重試 i18n_datasource_check_fail=校驗失敗,請檢查配置信息 i18n_not_find_user=未找到用戶 i18n_sql_not_empty=SQL 不能為空 -i18n_task_name_repeat=同一數據集下任務名稱已被使用 \ No newline at end of file +i18n_task_name_repeat=同一數據集下任務名稱已被使用 +i18n_id_or_pwd_error=無效的ID或密碼 \ No newline at end of file diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js index be2fd0c6f7..504e2d5a4b 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -283,7 +283,9 @@ export default { }, datasource: 'Datasource', char_can_not_more_50: 'Can not more 50 char', - share_success: 'Share Success' + share_success: 'Share Success', + input_id: 'Please input ID', + input_pwd: 'Please input password' }, documentation: { documentation: 'Documentation', diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index 0cab493eb2..44faae5d4f 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -283,7 +283,9 @@ export default { }, datasource: '數據源', char_can_not_more_50: '不能超過50字符', - share_success: '分享成功' + share_success: '分享成功', + input_id: '請輸入ID', + input_pwd: '請輸入密碼' }, documentation: { documentation: '文檔', diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index 1ee7c1759d..6324580114 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -283,7 +283,9 @@ export default { }, datasource: '数据源', char_can_not_more_50: '不能超过50字符', - share_success: '分享成功' + share_success: '分享成功', + input_id: '请输入ID', + input_pwd: '请输入密码' }, documentation: { documentation: '文档', diff --git a/frontend/src/views/login/index.vue b/frontend/src/views/login/index.vue index 02a47191ce..43f2b171b5 100644 --- a/frontend/src/views/login/index.vue +++ b/frontend/src/views/login/index.vue @@ -84,8 +84,8 @@ export default { password: '' }, loginRules: { - username: [{ required: true, trigger: 'blur', validator: validateUsername }], - password: [{ required: true, trigger: 'blur', validator: validatePassword }] + username: [{ required: true, trigger: 'blur', message: this.$t('commons.input_id') }], + password: [{ required: true, trigger: 'blur', message: this.$t('commons.input_pwd') }] }, loading: false, passwordType: 'password',