From d446ba75acc05ec331540d51348bdc2be5aecb42 Mon Sep 17 00:00:00 2001 From: Alexander Alexeev Date: Mon, 12 Dec 2016 16:58:18 +0700 Subject: rtemplate refactoring: layout templates moved to layout directory; show error message on login error --- .../juick/www/configuration/WebSecurityConfig.java | 2 +- .../com/juick/www/controllers/IndexController.java | 9 +- .../src/main/resources/errors.properties | 4 +- .../src/main/resources/errors_en.properties | 4 +- .../src/main/webapp/WEB-INF/templates/index.html | 17 +++ .../webapp/WEB-INF/templates/layout/login.html | 145 +++++++++++++++++++++ .../WEB-INF/templates/layout/mainLayout.html | 2 +- .../WEB-INF/templates/layout/partial/footer.html | 39 ++++++ .../templates/layout/partial/navigation.html | 50 +++++++ .../main/webapp/WEB-INF/templates/views/login.html | 144 -------------------- .../WEB-INF/templates/views/partial/footer.html | 40 ------ .../templates/views/partial/homecolumn.html | 9 +- .../templates/views/partial/navigation.html | 50 ------- 13 files changed, 275 insertions(+), 240 deletions(-) create mode 100644 juick-spring-www/src/main/webapp/WEB-INF/templates/index.html create mode 100644 juick-spring-www/src/main/webapp/WEB-INF/templates/layout/login.html create mode 100644 juick-spring-www/src/main/webapp/WEB-INF/templates/layout/partial/footer.html create mode 100644 juick-spring-www/src/main/webapp/WEB-INF/templates/layout/partial/navigation.html delete mode 100644 juick-spring-www/src/main/webapp/WEB-INF/templates/views/login.html delete mode 100644 juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/footer.html delete mode 100644 juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/navigation.html (limited to 'juick-spring-www/src/main') diff --git a/juick-spring-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java b/juick-spring-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java index bb6387d6..d10f2532 100644 --- a/juick-spring-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java +++ b/juick-spring-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java @@ -51,7 +51,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { .loginProcessingUrl("/do_login") .usernameParameter("j_username") .passwordParameter("j_password") - .failureUrl("/login?error=1") + .failureUrl("/login-error") .and() .rememberMe() .tokenValiditySeconds(6 * 30 * 24 * 3600) diff --git a/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java b/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java index 6f25844f..4df4d350 100644 --- a/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java +++ b/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java @@ -11,6 +11,7 @@ import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.context.MessageSource; import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -121,6 +122,12 @@ public class IndexController { @RequestMapping(value = "/login", method = RequestMethod.GET) public String getLoginForm() { - return "views/login"; + return "layout/login"; + } + + @RequestMapping(value = "/login-error", method = RequestMethod.GET) + public String getLoginErrorForm(Model model) { + model.addAttribute("loginError", true); + return "layout/login"; } } \ No newline at end of file diff --git a/juick-spring-www/src/main/resources/errors.properties b/juick-spring-www/src/main/resources/errors.properties index e0e14c56..e000394e 100644 --- a/juick-spring-www/src/main/resources/errors.properties +++ b/juick-spring-www/src/main/resources/errors.properties @@ -1,4 +1,6 @@ error.pageNotFound = Страница не найдена errors.pageNotFound.extended = Похоже, пользователь удалил пост #{0}, или пост не был создан. error.userNotFound = Пользователь не найден -errors.userNotFound.extended = Пользователь {0} не найден \ No newline at end of file +errors.userNotFound.extended = Пользователь {0} не найден + +error.login=Произошла ошибка, проверьте имя пользователя и пароль \ No newline at end of file diff --git a/juick-spring-www/src/main/resources/errors_en.properties b/juick-spring-www/src/main/resources/errors_en.properties index 99e70b14..7824bbe1 100644 --- a/juick-spring-www/src/main/resources/errors_en.properties +++ b/juick-spring-www/src/main/resources/errors_en.properties @@ -1,4 +1,6 @@ error.pageNotFound = Page not found errors.pageNotFound.extended = Probably, user deleted this post #{0}, or this post never existed. error.userNotFound = User not found -errors.userNotFound.extended = User {0} not found \ No newline at end of file +errors.userNotFound.extended = User {0} not found + +error.login=Wrong user or password \ No newline at end of file diff --git a/juick-spring-www/src/main/webapp/WEB-INF/templates/index.html b/juick-spring-www/src/main/webapp/WEB-INF/templates/index.html new file mode 100644 index 00000000..4cd32be3 --- /dev/null +++ b/juick-spring-www/src/main/webapp/WEB-INF/templates/index.html @@ -0,0 +1,17 @@ + + + + Главная страница + + + +
+

Главная страница !

+
+ + + \ No newline at end of file diff --git a/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/login.html b/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/login.html new file mode 100644 index 00000000..9fd43192 --- /dev/null +++ b/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/login.html @@ -0,0 +1,145 @@ + + + + + + + + Juick + + + + + + + + +
juick.com © 2008-2017   Контакты · Помощь
+ +
+ Зарегистрироваться: +
Facebook
+
VK
+
XMPP +
[(#{message.sendLoginToXmpp})]
+
+
+
+ Уже зарегистрированы? +
+

Произошла ошибка, проверьте имя пользователя и пароль

+
+ + + +
+
+
+ + \ No newline at end of file diff --git a/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/mainLayout.html b/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/mainLayout.html index e851aefa..ef9887d2 100644 --- a/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/mainLayout.html +++ b/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/mainLayout.html @@ -25,6 +25,6 @@

Side column

- + \ No newline at end of file diff --git a/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/partial/footer.html b/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/partial/footer.html new file mode 100644 index 00000000..0e4e8540 --- /dev/null +++ b/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/partial/footer.html @@ -0,0 +1,39 @@ + + + + + + + + + \ No newline at end of file diff --git a/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/partial/navigation.html b/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/partial/navigation.html new file mode 100644 index 00000000..95714e10 --- /dev/null +++ b/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/partial/navigation.html @@ -0,0 +1,50 @@ + + + + +
+ + + +
+ + + + + +

[(#{message.loginForSending(@{/login})})]

+
+
+
+ + diff --git a/juick-spring-www/src/main/webapp/WEB-INF/templates/views/login.html b/juick-spring-www/src/main/webapp/WEB-INF/templates/views/login.html deleted file mode 100644 index d2e424cd..00000000 --- a/juick-spring-www/src/main/webapp/WEB-INF/templates/views/login.html +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - - - Juick - - - - - - - - -
juick.com © 2008-2017   Контакты · Помощь
- -
- Зарегистрироваться: -
Facebook
-
VK
-
XMPP -
[(#{message.sendLoginToXmpp})]
-
-
-
- Уже зарегистрированы? -
-
- - - -
-
-
- - \ No newline at end of file diff --git a/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/footer.html b/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/footer.html deleted file mode 100644 index da911619..00000000 --- a/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/footer.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/homecolumn.html b/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/homecolumn.html index 534e0368..2f0d707c 100644 --- a/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/homecolumn.html +++ b/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/homecolumn.html @@ -1,4 +1,11 @@ + + + +

Tags
конструктор сайтов -

\ No newline at end of file +

+ + diff --git a/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/navigation.html b/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/navigation.html deleted file mode 100644 index 77c9321a..00000000 --- a/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/navigation.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - -
- - - -
- - - - - -

[(#{message.loginForSending(@{/login})})]

-
-
-
- - -- cgit v1.2.3