Skip to content

Commit 166a8b8

Browse files
committed
fix: update login/register failed msg
1 parent 16f1a2b commit 166a8b8

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

base/src/main/java/com/tinyengine/it/common/exception/ExceptionEnum.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,23 @@ public enum ExceptionEnum implements IBaseError {
336336
/**
337337
* Cm 342 exception enum.
338338
*/
339-
CM342("CM342", "数字格式异常");
339+
CM342("CM342", "数字格式异常"),
340+
341+
342+
/**
343+
* Cm 343 exception enum.
344+
*/
345+
CM343("CM343", "该用户名已被注册,请尝试其他名称"),
346+
347+
/**
348+
* Cm 344 exception enum.
349+
*/
350+
CM344("CM344", "账户恢复代码无效"),
351+
352+
/**
353+
* Cm 345 exception enum.
354+
*/
355+
CM345("CM345", "用户名不存在,请重新输入"),;
340356
/**
341357
* 错误码
342358
*/

base/src/main/java/com/tinyengine/it/login/service/impl/LoginServiceImpl.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public User createUser(User user) throws Exception {
5858
userParam.setUsername(user.getUsername());
5959
List<User> users = baseMapper.queryUserByCondition(userParam);
6060
if (!users.isEmpty()) {
61-
throw new ServiceException(ExceptionEnum.CM003.getResultCode(),
62-
ExceptionEnum.CM003.getResultMsg());
61+
throw new ServiceException(ExceptionEnum.CM343.getResultCode(),
62+
ExceptionEnum.CM343.getResultMsg());
6363
}
6464
KeyPair keyPair = generateSM2KeyPair();
6565
PublicKey publicKey = keyPair.getPublic();
@@ -98,14 +98,19 @@ public Result forgotPassword(User user) throws Exception {
9898
userParam.setUsername(user.getUsername());
9999
List<User> users = baseMapper.queryUserByCondition(userParam);
100100
if (users.isEmpty()) {
101-
return Result.failed(ExceptionEnum.CM002);
101+
return Result.failed(ExceptionEnum.CM345);
102102
}
103103
User userResult = users.get(0);
104-
PublicKey publicKey = getPublicKeyFromBase64(user.getPublicKey());
104+
PublicKey publicKey;
105+
try {
106+
publicKey = getPublicKeyFromBase64(user.getPublicKey());
107+
} catch (Exception e) {
108+
return Result.failed(ExceptionEnum.CM344);
109+
}
105110
PrivateKey privateKey = getPrivateKeyFromBase64(userResult.getPrivateKey());
106111
// 验证publickey
107112
if (!validatorPublicKey(userResult.getSalt(), publicKey, privateKey)) {
108-
return Result.failed(ExceptionEnum.CM335);
113+
return Result.failed(ExceptionEnum.CM344);
109114
}
110115
String cipherText = encrypt(user.getSalt(), publicKey);
111116
user.setSalt(cipherText);

base/src/main/java/com/tinyengine/it/service/app/impl/AppServiceImpl.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,20 @@ public Result<App> updateAppById(App app) {
180180
appExtendConfig.remove("route");
181181
app.getExtendConfig().putAll(appExtendConfig);
182182
}
183+
String tenantId = app.getTenantId();
184+
if(tenantId == null) {
185+
tenantId = loginUserContext.getTenantId();
186+
app.setTenantId(tenantId);
187+
}
188+
App appselect = baseMapper.queryAppById(app.getId(), tenantId);
189+
if(appselect == null) {
190+
return Result.failed(ExceptionEnum.CM009);
191+
}
183192
int result = baseMapper.updateAppById(app);
184193
if (result < 1) {
185194
return Result.failed(ExceptionEnum.CM001);
186195
}
187-
App selectedApp = baseMapper.queryAppById(app.getId(), loginUserContext.getTenantId());
196+
App selectedApp = baseMapper.queryAppById(app.getId(), tenantId);
188197
return Result.success(selectedApp);
189198
}
190199

0 commit comments

Comments
 (0)