diff --git a/build.gradle b/build.gradle index 23bab4e14ddced39c4d244c67ef0e822722c81ff..cb5f573cc10ea35ff24ce651c551df82c32873e7 100644 --- a/build.gradle +++ b/build.gradle @@ -37,6 +37,7 @@ dependencies { testImplementation 'org.springframework.boot:spring-boot-starter-test' implementation 'org.springframework.boot:spring-boot-starter-validation' implementation 'org.springframework.boot:spring-boot-starter-security' + implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6:3.1.1.RELEASE' // https://mvnrepository.com/artifact/org.webjars/openlayers implementation group: 'org.webjars', name: 'openlayers', version: '5.2.0' } diff --git a/src/main/java/Team5/SmartTowns/rewards/RewardsRepositoryJDBC.java b/src/main/java/Team5/SmartTowns/rewards/RewardsRepositoryJDBC.java index e824428f94232e6daa61b2f39b8152d2c1901257..74c97a5f29319ab6dbefc042bcbc10e364b4bd03 100644 --- a/src/main/java/Team5/SmartTowns/rewards/RewardsRepositoryJDBC.java +++ b/src/main/java/Team5/SmartTowns/rewards/RewardsRepositoryJDBC.java @@ -59,7 +59,7 @@ public class RewardsRepositoryJDBC implements RewardsRepository { /* FINDS ALL STICKERS UNLOCKED BY THE GIVEN USER */ String sql= "SELECT * FROM stickers LEFT JOIN stickerprogress " + "ON (stickers.id, stickers.packID) = (stickerprogress.stickerID, stickerprogress.packID) " + - "WHERE stickerprogress.userID = ? "; + "WHERE stickerprogress.username = ? "; return jdbc.query(sql, stickerMapper, userID); } diff --git a/src/main/java/Team5/SmartTowns/users/UserController.java b/src/main/java/Team5/SmartTowns/users/UserController.java index b1e96db4eee34e2b1f652ca3ecdaa9736a047923..1cc58ecd2cd8bd7d1a50e1a5fa68bc53897699e6 100644 --- a/src/main/java/Team5/SmartTowns/users/UserController.java +++ b/src/main/java/Team5/SmartTowns/users/UserController.java @@ -6,6 +6,7 @@ import Team5.SmartTowns.rewards.RewardsRepository; import Team5.SmartTowns.rewards.Sticker; import jakarta.validation.Valid; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.Banner; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.User; import org.springframework.stereotype.Controller; @@ -34,6 +35,12 @@ public class UserController { return mav; } + @GetMapping("/logout") + public ModelAndView getLogOutPage(){ + ModelAndView mav = new ModelAndView("users/logout"); + return mav; + } + @PostMapping("/login/register") public ModelAndView registerUser(@Valid @ModelAttribute("user") NewUser user, BindingResult bindingResult, Model model) { ModelAndView mav = new ModelAndView("users/login", model.asMap()); diff --git a/src/main/resources/static/css/style.css b/src/main/resources/static/css/style.css index ca8e94887f7ff4975d6b8859f24f105b14a2ca8d..934cac13d9ed4bfebab932cc72b6839e0869b25b 100644 --- a/src/main/resources/static/css/style.css +++ b/src/main/resources/static/css/style.css @@ -52,6 +52,12 @@ body { justify-content: center; align-content: center; } +.centerAll { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} /*PHONES PORTRAIT*/ @media only screen diff --git a/src/main/resources/templates/allTrails/allTrails.html b/src/main/resources/templates/allTrails/allTrails.html index d29d1ad91cf459383b4681678742ed0a2cacbcd6..0fefa92c95a928454c100894149bf18340015baf 100644 --- a/src/main/resources/templates/allTrails/allTrails.html +++ b/src/main/resources/templates/allTrails/allTrails.html @@ -11,7 +11,7 @@ <body> <header th:replace="~{/fragments/Templating.html :: header}"></header> - +<div>TEST</div> <main> <section id="allTrailsBar" class="centerFlex"> <img class="trailsImages" diff --git a/src/main/resources/templates/fragments/Templating.html b/src/main/resources/templates/fragments/Templating.html index 871e541bd8767e721d139cedfa8dd193b5212987..e3afc23854e38d5973a596f44e8d546305b59b83 100644 --- a/src/main/resources/templates/fragments/Templating.html +++ b/src/main/resources/templates/fragments/Templating.html @@ -9,15 +9,15 @@ <li><a id="homeHead" href="/home">Home</a></li> <li>FAQs</li> <li>Contact us</li> + <li th:if="${#authentication.principal}!=anonymousUser"><a href="/logout">Log Out</a></li> + <li th:if="${#authentication.principal}==anonymousUser"><a href="/login">Log In</a></li> </ul> - <label class="work">Who we Work with:</label> - <select> - <ul> - <option value="localauthorities">Local Authorities</option> - <option value="towns">Towns</option> - <option value="businesses">Businesses</option> - <option value="consumers">Consumers</option> - </ul> + <label for="stakeholders" class="work">Who we Work with:</label> + <select id="stakeholders"> + <option value="localauthorities">Local Authorities</option> + <option value="towns">Towns</option> + <option value="businesses">Businesses</option> + <option value="consumers">Consumers</option> </select> </nav> </header> diff --git a/src/main/resources/templates/users/logout.html b/src/main/resources/templates/users/logout.html new file mode 100644 index 0000000000000000000000000000000000000000..69107ce66e4b6c4b3ed49219e191e5335de6d9a2 --- /dev/null +++ b/src/main/resources/templates/users/logout.html @@ -0,0 +1,17 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>Logged Out Successfully</title> + <link rel="stylesheet" th:href="@{/css/style.css}"> + <link rel="stylesheet" th:href="@{/css/login.css}"> +</head> +<body> +<main> + <div class="container centerAll"> + <h1>You have successfully logged out</h1> + </div> +</main> + +</body> +</html> \ No newline at end of file