Revize 17ad8bc7
Přidáno uživatelem Jan Čarnogurský před téměř 5 roky(ů)
src/main/java/vldc/aswi/configuration/AppConfig.java | ||
---|---|---|
93 | 93 |
.defaultSuccessUrl("/", true) |
94 | 94 |
.and() |
95 | 95 |
.logout() |
96 |
.logoutRequestMatcher(new RegexRequestMatcher("/logout", "GET"))
|
|
96 |
.logoutRequestMatcher(new RegexRequestMatcher("/logout", "POST"))
|
|
97 | 97 |
.invalidateHttpSession(true) |
98 | 98 |
.deleteCookies("JSESSIONID") |
99 | 99 |
.permitAll(); |
src/main/java/vldc/aswi/web/controller/LoginController.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import org.springframework.stereotype.Controller; |
4 | 4 |
import org.springframework.web.bind.annotation.GetMapping; |
5 |
import org.springframework.web.bind.annotation.PostMapping; |
|
5 | 6 |
import org.springframework.web.servlet.ModelAndView; |
6 | 7 |
|
7 | 8 |
@Controller |
... | ... | |
18 | 19 |
return modelAndView; |
19 | 20 |
} |
20 | 21 |
|
22 |
/** |
|
23 |
* Logout. |
|
24 |
* @return the string |
|
25 |
*/ |
|
26 |
@PostMapping(value = "/logout") |
|
27 |
public String logout() |
|
28 |
{ |
|
29 |
return "redirect:/login"; |
|
30 |
} |
|
31 |
|
|
21 | 32 |
} |
src/main/webapp/WEB-INF/templates/layouts/layout.html | ||
---|---|---|
1 | 1 |
<!DOCTYPE html> |
2 | 2 |
<html lang="en" xmlns:th="http://www.thymeleaf.org" |
3 |
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"> |
|
3 |
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:sec="http://www.w3.org/1999/xhtml">
|
|
4 | 4 |
<head> |
5 | 5 |
<meta charset="utf-8"> |
6 | 6 |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
... | ... | |
40 | 40 |
</div> |
41 | 41 |
</div> |
42 | 42 |
|
43 |
<div sec:authorize="isAuthenticated()" class="user-panel"> |
|
44 |
<span>Přihlášen: <span sec:authentication="name"></span></span> |
|
45 |
<a href="#" onclick="document.forms['logoutForm'].submit()">Odhlásit se</a> |
|
46 |
|
|
47 |
<form id="logoutForm" method="POST" th:action="@{/logout}"> |
|
48 |
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/> |
|
49 |
</form> |
|
50 |
</div> |
|
51 |
|
|
43 | 52 |
<main role="main"> |
44 | 53 |
<div layout:fragment="content"></div> |
45 | 54 |
</main> |
src/main/webapp/css/style.css | ||
---|---|---|
322 | 322 |
.hidden { |
323 | 323 |
display: none !important; |
324 | 324 |
} |
325 |
|
|
326 |
.user-panel { |
|
327 |
text-align: right; |
|
328 |
padding-right: 20px; |
|
329 |
padding-top: 20px; |
|
330 |
} |
Také k dispozici: Unified diff
re #8015 added user logout