tomsun28 commented on code in PR #1957:
URL: https://github.com/apache/hertzbeat/pull/1957#discussion_r1597340462
##########
manager/src/main/java/org/apache/hertzbeat/manager/controller/AccountController.java:
##########
@@ -66,11 +68,14 @@ public class AccountController {
@PostMapping("/form")
@Operation(summary = "Account password login to obtain associated user
information", description = "Account password login to obtain associated user
information")
public ResponseEntity<Message<Map<String, String>>> authGetToken(@Valid
@RequestBody LoginDto loginDto) {
- SurenessAccount account =
accountProvider.loadAccount(loginDto.getIdentifier());
+ if (StringUtils.isBlank(loginDto.getIdentifier()) ||
StringUtils.isBlank(loginDto.getCredential())) {
+ return ResponseEntity.ok(Message.fail(MONITOR_LOGIN_FAILED_CODE, "
identifier or credential is null"));
+ }
+ SurenessAccount account =
accountProvider.loadAccount(loginDto.getIdentifier().trim());
if (account == null || account.getPassword() == null) {
return ResponseEntity.ok(Message.fail(MONITOR_LOGIN_FAILED_CODE,
"Incorrect Account or Password"));
} else {
- String password = loginDto.getCredential();
+ String password = loginDto.getCredential().trim();
Review Comment:
hi, here we not suggest use the trim(), we donot need to update the username
password the user input.
StringUtils.isBlank is no need, because the @Valid LoginDto has the vaild
rule.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]