From d70f7cf3cf5afbfa3d9ca396068d9ff4bfe4046f Mon Sep 17 00:00:00 2001
From: xufenglei <xufenglei>
Date: Mon, 22 Jul 2019 15:21:06 +0800
Subject: [PATCH] app更新

---
 src/main/java/com/moral/security/auth/login/LoginAwareAuthenticationFailureHandler.java |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/moral/security/auth/login/LoginAwareAuthenticationFailureHandler.java b/src/main/java/com/moral/security/auth/login/LoginAwareAuthenticationFailureHandler.java
index 1f943db..35b73c0 100644
--- a/src/main/java/com/moral/security/auth/login/LoginAwareAuthenticationFailureHandler.java
+++ b/src/main/java/com/moral/security/auth/login/LoginAwareAuthenticationFailureHandler.java
@@ -3,6 +3,7 @@
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.moral.security.common.ErrorCode;
 import com.moral.security.common.ErrorResponse;
+import com.moral.security.exceptions.AccountExpiredBadCredentialsException;
 import com.moral.security.exceptions.AuthMethodNotSupportedException;
 import com.moral.security.exceptions.JwtExpiredTokenException;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -40,14 +41,17 @@
 		response.setStatus(HttpStatus.UNAUTHORIZED.value());
 		response.setContentType(MediaType.APPLICATION_JSON_VALUE);
 		
-		if (e instanceof BadCredentialsException) {
+		if(e instanceof AccountExpiredBadCredentialsException){
+			mapper.writeValue(response.getWriter(), ErrorResponse.of(e.getMessage(), ErrorCode.ACCOUNT_EXPIRED, HttpStatus.UNAUTHORIZED));
+		}else  if (e instanceof BadCredentialsException) {
 			mapper.writeValue(response.getWriter(), ErrorResponse.of("Invalid username or password", ErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
 		} else if (e instanceof JwtExpiredTokenException) {
 			mapper.writeValue(response.getWriter(), ErrorResponse.of("Token has expired", ErrorCode.JWT_TOKEN_EXPIRED, HttpStatus.UNAUTHORIZED));
 		} else if (e instanceof AuthMethodNotSupportedException) {
 		    mapper.writeValue(response.getWriter(), ErrorResponse.of(e.getMessage(), ErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
+		}  else {
+			mapper.writeValue(response.getWriter(), ErrorResponse.of(e.getMessage(), ErrorCode.AUTHENTICATION, HttpStatus.OK));
 		}
-		mapper.writeValue(response.getWriter(), ErrorResponse.of("Authentication failed", ErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
-//		mapper.writeValue(response.getWriter(), ErrorResponse.of(e.getMessage(), ErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
+//		mapper.writeValue(response.getWriter(), ErrorResponse.of("Authentication failed", ErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
 	}
 }

--
Gitblit v1.8.0