Commit 91861072 authored by Marek Kadlečík's avatar Marek Kadlečík
Browse files

Removed session=false qualifier from page tag in all jsp files + added...

Removed session=false qualifier from page tag in all jsp files + added authentication test in UI to show elements accordingly
parent 79e5b894
Pipeline #141958 passed with stage
in 1 minute and 2 seconds
......@@ -22,6 +22,7 @@ You can run the Online Gaming Management System with maven:
- `cd gaming-spring-mvc` move to the module of the web app
- execute `mvn cargo:run` to start the server
- UI - open `http://localhost:8080/pa165/` in the browser
- Use username `poter` and password `admin` to access administrative functionality
#### REST demo
We exposed `Player` entity in REST API. Execute `mvn cargo:run` on rest module to run rest api.
......
......@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.validation.Valid;
......@@ -42,7 +43,7 @@ public class LoginController {
}
@PostMapping(value = "/login")
public String postLogin(Model model, HttpSession session, @Valid @ModelAttribute("user") PersonDTO personDTO,
public String postLogin(Model model, HttpServletRequest request, @Valid @ModelAttribute("user") PersonDTO personDTO,
BindingResult bindingResult, RedirectAttributes redirectAttributes) {
......@@ -62,7 +63,7 @@ public class LoginController {
return "security/loginFailed";
}
session.setAttribute("authenticatedUser", mapper.mapTo(person, PersonDTO.class));
request.getSession().setAttribute("authenticatedUser", mapper.mapTo(person, PersonDTO.class));
redirectAttributes.addFlashAttribute("alert_success", "Login successful!");
return "redirect:/";
}
......
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="true" session="false" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="true" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
......
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" session="false" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
......@@ -8,10 +8,12 @@
<my:pagetemplate title="Matches">
<jsp:attribute name="body">
<my:a href="/match/new" class="btn btn-primary">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
New match
</my:a>
<c:if test="${not empty sessionScope.authenticatedUser}">
<my:a href="/match/new" class="btn btn-primary">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
New match
</my:a>
</c:if>
<table class="table">
<thead>
......@@ -32,11 +34,13 @@
<td>
<my:a href="/match/view/${match.id}" class="btn btn-primary">View</my:a>
</td>
<td>
<form method="post" action="${pageContext.request.contextPath}/match/delete/${match.id}">
<button type="submit" class="btn btn-primary">Delete</button>
</form>
</td>
<c:if test="${not empty sessionScope.authenticatedUser}">
<td>
<form method="post" action="${pageContext.request.contextPath}/match/delete/${match.id}">
<button type="submit" class="btn btn-primary">Delete</button>
</form>
</td>
</c:if>
</tr>
</c:forEach>
</tbody>
......
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" session="false" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
......
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" session="false" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
......@@ -8,9 +8,11 @@
<my:pagetemplate title="Match Administration">
<jsp:attribute name="body">
<form method="post" action="${pageContext.request.contextPath}/match/delete/${match.id}">
<button type="submit" class="btn btn-primary">Delete</button>
</form>
<c:if test="${not empty sessionScope.authenticatedUser}">
<form method="post" action="${pageContext.request.contextPath}/match/delete/${match.id}">
<button type="submit" class="btn btn-primary">Delete</button>
</form>
</c:if>
<table class="table">
......
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" session="false" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
......
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" session="false" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
......@@ -8,10 +8,12 @@
<my:pagetemplate title="Players">
<jsp:attribute name="body">
<my:a href="/player/new" class="btn btn-primary">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
New Player
</my:a>
<c:if test="${not empty sessionScope.authenticatedUser}">
<my:a href="/player/new" class="btn btn-primary">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
New Player
</my:a>
</c:if>
<table class="table">
<thead>
......@@ -38,11 +40,13 @@
<td>
<my:a href="/player/view/${player.id}" class="btn btn-primary">View</my:a>
</td>
<td>
<form method="post" action="${pageContext.request.contextPath}/player/delete/${player.id}">
<button type="submit" class="btn btn-primary">Delete</button>
</form>
</td>
<c:if test="${not empty sessionScope.authenticatedUser}">
<td>
<form method="post" action="${pageContext.request.contextPath}/player/delete/${player.id}">
<button type="submit" class="btn btn-primary">Delete</button>
</form>
</td>
</c:if>
</tr>
</c:forEach>
</tbody>
......
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" session="false" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
......
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" session="false" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
......@@ -7,22 +7,24 @@
<my:pagetemplate title="Player Administration">
<jsp:attribute name="body">
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-2 col-lg-1">
<form method="post" action="${pageContext.request.contextPath}/player/delete/${player.id}">
<button type="submit" class="btn btn-primary ">
<span class="glyphicon glyphicon-minus"></span>
Delete</button>
</form>
<c:if test="${not empty sessionScope.authenticatedUser}">
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-2 col-lg-1">
<form method="post" action="${pageContext.request.contextPath}/player/delete/${player.id}">
<button type="submit" class="btn btn-primary ">
<span class="glyphicon glyphicon-minus"></span>
Delete</button>
</form>
</div>
<div class="col-xs-12 col-sm-6 col-md-2 col-lg-1">
<form method="post" action="${pageContext.request.contextPath}/player/edit/${player.id}">
<button type="submit" class="btn btn-primary ">
<span class="glyphicon glyphicon-asterisk"></span>
Edit</button>
</form>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-2 col-lg-1">
<form method="post" action="${pageContext.request.contextPath}/player/edit/${player.id}">
<button type="submit" class="btn btn-primary ">
<span class="glyphicon glyphicon-asterisk"></span>
Edit</button>
</form>
</div>
</div>
</c:if>
<table class="table">
<thead>
......
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="true" session="false" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="true" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
......
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="true" session="false" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="true" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
......
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="true" session="false" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="true" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
......
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="true" session="false" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="true" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
......
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" session="false" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
......@@ -8,10 +8,12 @@
<my:pagetemplate title="Teams">
<jsp:attribute name="body">
<my:a href="/team/new" class="btn btn-primary">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
New team
</my:a>
<c:if test="${not empty sessionScope.authenticatedUser}">
<my:a href="/team/new" class="btn btn-primary">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
New team
</my:a>
</c:if>
<table class="table">
<thead>
......@@ -30,11 +32,13 @@
<td>
<my:a href="/team/view/${team.id}" class="btn btn-primary">View</my:a>
</td>
<td>
<form method="post" action="${pageContext.request.contextPath}/team/delete/${team.id}">
<button type="submit" class="btn btn-primary">Delete</button>
</form>
</td>
<c:if test="${not empty sessionScope.authenticatedUser}">
<td>
<form method="post" action="${pageContext.request.contextPath}/team/delete/${team.id}">
<button type="submit" class="btn btn-primary">Delete</button>
</form>
</td>
</c:if>
</tr>
</c:forEach>
</tbody>
......
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" session="false" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
......
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" session="false" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
......
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" session="false" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
......@@ -8,10 +8,12 @@
<my:pagetemplate title="Tournaments">
<jsp:attribute name="body">
<my:a href="/tournament/new" class="btn btn-primary">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
New tournament
</my:a>
<c:if test="${not empty sessionScope.authenticatedUser}">
<my:a href="/tournament/new" class="btn btn-primary">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
New tournament
</my:a>
</c:if>
<table class="table">
<thead>
......@@ -39,11 +41,13 @@
<td>
<my:a href="/tournament/view/${tournament.id}" class="btn btn-primary">View</my:a>
</td>
<td>
<form method="post" action="${pageContext.request.contextPath}/tournament/delete/${tournament.id}">
<button type="submit" class="btn btn-primary">Delete</button>
</form>
</td>
<c:if test="${not empty sessionScope.authenticatedUser}">
<td>
<form method="post" action="${pageContext.request.contextPath}/tournament/delete/${tournament.id}">
<button type="submit" class="btn btn-primary">Delete</button>
</form>
</td>
</c:if>
</tr>
</c:forEach>
</tbody>
......
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" session="false" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
......
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" session="false" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="false" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
......@@ -8,9 +8,11 @@
<my:pagetemplate title="Tournament Administration">
<jsp:attribute name="body">
<form method="post" action="${pageContext.request.contextPath}/tournament/delete/${tournament.id}">
<button type="submit" class="btn btn-primary">Delete</button>
</form>
<c:if test="${not empty sessionScope.authenticatedUser}">
<form method="post" action="${pageContext.request.contextPath}/tournament/delete/${tournament.id}">
<button type="submit" class="btn btn-primary">Delete</button>
</form>
</c:if>
<table class="table">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment