aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/www
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2021-03-25 16:32:55 +0300
committerGravatar Vitaly Takmazov2021-03-25 16:32:55 +0300
commitb4608708f6f0f2e0d8ae846da3c490cf894d2b46 (patch)
treee283025479df86cb0ae301efd3bbf4742216d3d2 /src/main/java/com/juick/www
parent2181b5c3259bc2312513fdc384456d3392a82931 (diff)
login page refactoring
* drop jQuery * merge styles * show login error message
Diffstat (limited to 'src/main/java/com/juick/www')
-rw-r--r--src/main/java/com/juick/www/controllers/Login.java19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/main/java/com/juick/www/controllers/Login.java b/src/main/java/com/juick/www/controllers/Login.java
index 8f3e9e9a4..33fcc0111 100644
--- a/src/main/java/com/juick/www/controllers/Login.java
+++ b/src/main/java/com/juick/www/controllers/Login.java
@@ -19,12 +19,16 @@ package com.juick.www.controllers;
import com.juick.model.User;
import com.juick.service.UserService;
import com.juick.service.security.annotation.Visitor;
+
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.web.WebAttributes;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.inject.Inject;
+import javax.servlet.http.HttpSession;
/**
* @author Ugnich Anton
@@ -35,14 +39,21 @@ public class Login {
private UserService userService;
@GetMapping("/login")
- public String getloginForm(
- @Visitor User visitor,
- @RequestParam(required = false, defaultValue = "true") boolean redirect) {
+ public String getloginForm(@Visitor User visitor, HttpSession session,
+ @RequestParam(required = false, defaultValue = "true") boolean redirect, ModelMap model) {
if (!visitor.isAnonymous()) {
return redirect ? "redirect:/" : "redirect:/login/success";
}
- return "views/login";
+ AuthenticationException authEx = (AuthenticationException) session
+ .getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
+
+ if (authEx != null) {
+ model.addAttribute("authErrorMessage", authEx.getLocalizedMessage());
+ }
+
+ return "layouts/login";
}
+
@GetMapping("/login/success")
public String getSuccessLogin(@Visitor User visitor, ModelMap model) {
model.addAttribute("hash", userService.getHashByUID(visitor.getUid()));