提交 71d53daa 编写于 作者: M MaxKey

login fail message

上级 97b3bd10
......@@ -76,6 +76,11 @@ public class Message<T> {
public void setMessage(String message) {
this.message = message;
}
public void setMessage(int code,String message) {
this.code = code;
this.message = message;
}
public T getData() {
return data;
......
......@@ -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 . ");
......
......@@ -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();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册