|
|
@@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import com.uas.eis.entity.ErrorMsg;
|
|
|
+import com.uas.eis.exception.SystemException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.servlet.HandlerInterceptor;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
@@ -42,13 +43,11 @@ public class LoginInterceptor implements HandlerInterceptor{
|
|
|
|
|
|
private Claims parseToken(String token) {
|
|
|
if(token == null || token.isEmpty()) {
|
|
|
- BaseUtil.showError(ErrorMsg.NULL_TOKEN);
|
|
|
- return null;
|
|
|
+ throw new SystemException(ErrorMsg.NULL_TOKEN);
|
|
|
}
|
|
|
Claims claims = TokenHandler.parseToken(token);
|
|
|
if(claims == null) {
|
|
|
- BaseUtil.showError(ErrorMsg.INVALID_TOKEN);
|
|
|
- return null;
|
|
|
+ throw new SystemException(ErrorMsg.INVALID_TOKEN);
|
|
|
}
|
|
|
Date now = new Date();
|
|
|
Date start = claims.getNotBefore();
|
|
|
@@ -57,8 +56,7 @@ public class LoginInterceptor implements HandlerInterceptor{
|
|
|
if (now.after(start) && now.before(end)) {
|
|
|
return claims;
|
|
|
}else {
|
|
|
- BaseUtil.showError(ErrorMsg.EXPIRED_TOKEN);
|
|
|
- return null;
|
|
|
+ throw new SystemException(ErrorMsg.EXPIRED_TOKEN);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -68,7 +66,7 @@ public class LoginInterceptor implements HandlerInterceptor{
|
|
|
enable = userService.checkUser(username, password);
|
|
|
}
|
|
|
if(!enable) {
|
|
|
- BaseUtil.showError(ErrorMsg.INVALID_USER);
|
|
|
+ throw new SystemException(ErrorMsg.INVALID_USER);
|
|
|
}
|
|
|
return enable;
|
|
|
}
|
|
|
@@ -76,7 +74,7 @@ public class LoginInterceptor implements HandlerInterceptor{
|
|
|
private boolean checkActionAccess(String username, String action) {
|
|
|
boolean enable = userService.checkAction(username, action);
|
|
|
if(!enable) {
|
|
|
- BaseUtil.showError(ErrorMsg.PERMISSION_DENIED_REQUEST);
|
|
|
+ throw new SystemException(ErrorMsg.PERMISSION_DENIED_REQUEST);
|
|
|
}
|
|
|
return enable;
|
|
|
}
|