login fail message

This commit is contained in:
MaxKey
2022-07-05 15:37:39 +08:00
parent 97b3bd10b7
commit 71d53daa90
3 changed files with 21 additions and 3 deletions

View File

@@ -190,6 +190,11 @@ public class LoginEntryPoint {
(Integer)WebContext.getAttribute(WebConstants.CURRENT_USER_PASSWORD_SET_TYPE));
authJwtMessage = new Message<AuthJwt>(authJwt);
}else {//fail
String errorMsg = WebContext.getAttribute(WebConstants.LOGIN_ERROR_SESSION_MESSAGE) == null ?
"" : WebContext.getAttribute(WebConstants.LOGIN_ERROR_SESSION_MESSAGE).toString();
authJwtMessage.setMessage(errorMsg);
_logger.debug("login fail , message {}",errorMsg);
}
}else {
_logger.error("Login AuthN type must eq normal , tfa or mobile . ");

View File

@@ -81,12 +81,20 @@ public class LoginEntryPoint {
@RequestMapping(value={"/signin"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> signin( @RequestBody LoginCredential loginCredential) {
Message<AuthJwt> authJwtMessage = new Message<AuthJwt>(Message.FAIL);
if(authTokenService.validateJwtToken(loginCredential.getState())){
Authentication authentication = authenticationProvider.authenticate(loginCredential);
AuthJwt authJwt = authTokenService.genAuthJwt(authentication);
return new Message<AuthJwt>(authJwt).buildResponse();
if(authentication != null) {
AuthJwt authJwt = authTokenService.genAuthJwt(authentication);
authJwtMessage = new Message<AuthJwt>(authJwt);
}else {//fail
String errorMsg = WebContext.getAttribute(WebConstants.LOGIN_ERROR_SESSION_MESSAGE) == null ?
"" : WebContext.getAttribute(WebConstants.LOGIN_ERROR_SESSION_MESSAGE).toString();
authJwtMessage.setMessage(Message.FAIL,errorMsg);
_logger.debug("login fail , message {}",errorMsg);
}
}
return new Message<AuthJwt>(Message.FAIL).buildResponse();
return authJwtMessage.buildResponse();
}
}