Permalink
Browse files

LoginController: корректная обработка UserNotFoundException

  • Loading branch information...
1 parent f9c56a4 commit 3a353a274659cdf10b91dc74dea25de173cfcd34 @maxcom maxcom committed Apr 19, 2012
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/main/java/ru/org/linux/auth/LoginController.java
@@ -27,6 +27,7 @@
import ru.org.linux.user.User;
import ru.org.linux.user.UserBanedException;
import ru.org.linux.user.UserDao;
+import ru.org.linux.user.UserNotFoundException;
import ru.org.linux.util.StringUtil;
import javax.servlet.http.Cookie;
@@ -193,8 +194,17 @@ private void createCookies(HttpServletResponse response, HttpSession session, Us
*/
@ExceptionHandler(UserBanedException.class)
@ResponseStatus(HttpStatus.FORBIDDEN)
- public ModelAndView handleUserBanedException(UserBanedException ex, HttpServletRequest request, HttpServletResponse response) {
+ public ModelAndView handleUserBanedException(UserBanedException ex) {
return new ModelAndView("errors/user-banned", "exception", ex);
}
+ /**
+ * Обрабатываем исключительную ситуацию для забаненого пользователя
+ */
+ @ExceptionHandler(UserNotFoundException.class)
+ @ResponseStatus(HttpStatus.FORBIDDEN)
+ public ModelAndView handleUserNotFoundException(HttpServletRequest request) {
+ boolean ajax = isAjax(request);
+ return new ModelAndView(ajax ? "login-xml" : "login-form", Collections.singletonMap("error", "Неверный пароль"));
+ }
}

0 comments on commit 3a353a2

Please sign in to comment.