From dd5f06db6ba4010c1969de98386433c029311ff3 Mon Sep 17 00:00:00 2001 From: Githuba Richard <githubarj@cardiff.ac.uk> Date: Thu, 12 Dec 2024 13:36:53 +0000 Subject: [PATCH] some fixes --- .../polish_community/security/WebSecurityConfig.java | 2 +- src/main/resources/templates/event/event.html | 10 ++++++---- src/main/resources/templates/feed/feed.html | 8 +++++--- src/main/resources/templates/news/newsList.html | 10 ++++++---- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/main/java/polish_community_group_11/polish_community/security/WebSecurityConfig.java b/src/main/java/polish_community_group_11/polish_community/security/WebSecurityConfig.java index 3119b99..3b5e40a 100644 --- a/src/main/java/polish_community_group_11/polish_community/security/WebSecurityConfig.java +++ b/src/main/java/polish_community_group_11/polish_community/security/WebSecurityConfig.java @@ -37,7 +37,7 @@ public class WebSecurityConfig { private final String[] whiteListingPath = { // "/event", // "event/*" -// "/api/feed/**" , + "/feed" }; public WebSecurityConfig(UserService userService, RoleService roleService) { diff --git a/src/main/resources/templates/event/event.html b/src/main/resources/templates/event/event.html index c4e3731..ca7d771 100644 --- a/src/main/resources/templates/event/event.html +++ b/src/main/resources/templates/event/event.html @@ -1,7 +1,9 @@ <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" - layout:decorate="~{layout/layout}"> + layout:decorate="~{layout/layout}" + xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity6" +> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> @@ -12,7 +14,7 @@ <div id="event-details" class="event-details"> <div class="general-headings-layout"> <h1>Community Events</h1> - <a th:href="@{event/add}"><button class="add-event-button">Add Event</button></a> + <a th:href="@{event/add}"><button class="add-event-button" sec:authorize="isAuthenticated()" >Add Event</button></a> </div> <div class="event-grid"> <!-- Loop through each event and create a clickable link --> @@ -28,9 +30,9 @@ <p><strong>Location:</strong> <span th:text="${event.getLocation()}">Event location</span></p> </a> </div> - <div class ="event-card-button"> + <div class ="event-card-button" sec:authorize="isAuthenticated()"> <button class="register-button">Register Now</button> - <a th:href="@{/event/edit/{id}(id=${event.getEvent_id()})}" class="event-link"><button>Edit Event</button></a> + <a th:href="@{/event/edit/{id}(id=${event.getEvent_id()})}" class="event-link" ><button>Edit Event</button></a> </div> </div> </div> diff --git a/src/main/resources/templates/feed/feed.html b/src/main/resources/templates/feed/feed.html index 058d86c..84778d0 100644 --- a/src/main/resources/templates/feed/feed.html +++ b/src/main/resources/templates/feed/feed.html @@ -2,7 +2,9 @@ <html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" - layout:decorate="~{layout/layout}"> + layout:decorate="~{layout/layout}" + xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity6" +> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> @@ -19,7 +21,7 @@ <!-- posts will appear here --> <div id="postFeed" class="post-feed"> <!-- using template since I want to use it in javascript --> - <template id="post-template"> + <template id="post-template" > <div class="post"> <div class="post-header"> <div class="author-details"> @@ -71,7 +73,7 @@ </template> </div> - <button class="add-post" id="add-post"> + <button class="add-post" id="add-post" > <i class="bi bi-plus"></i> </button> <div id="create-new-modal" class="create-new-modal"> diff --git a/src/main/resources/templates/news/newsList.html b/src/main/resources/templates/news/newsList.html index 2e2a97c..bc22683 100644 --- a/src/main/resources/templates/news/newsList.html +++ b/src/main/resources/templates/news/newsList.html @@ -1,6 +1,8 @@ <!DOCTYPE html> <html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" - layout:decorate="~{layout/layout}"> + layout:decorate="~{layout/layout}" + xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity6" +> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> @@ -13,7 +15,7 @@ <section layout:fragment="content" class="content"> <div class="general-headings-layout"> <h1>Community News</h1> - <button onclick="openNewsForm()" id="openModalBtn" class="openModalBtn">Add News</button> + <button onclick="openNewsForm()" id="openModalBtn" class="openModalBtn" sec:authorize="isAuthenticated()" >Add News</button> </div> <main class="news-container"> <!-- Main news card --> @@ -29,7 +31,7 @@ </div> <div class="card-footer"> <p class="source">Source: <span th:text="${newsList[0].getNews_source()}"></span></p> - <a th:href="@{/editNews/{id}(id=${newsList[0].getNews_id()})}" class="modify-btn modify-link">Modify</a> + <a th:href="@{/editNews/{id}(id=${newsList[0].getNews_id()})}" class="modify-btn modify-link" sec:authorize="isAuthenticated()" >Modify</a> <p class="date" th:text="${newsList[0].getNews_upload_date()}"></p> </div> </div> @@ -42,7 +44,7 @@ <div class="card-footer"> <p class="source">Source: <span th:text="${news.getNews_source()}"></span></p> <p class="date" th:text="${news.getNews_upload_date()}"></p> - <a th:href="@{/editNews/{id}(id=${news.getNews_id()})}" class="modify-btn modify-link">Modify</a> + <a th:href="@{/editNews/{id}(id=${news.getNews_id()})}" class="modify-btn modify-link" sec:authorize="isAuthenticated()">Modify</a> </div> </div> </div> -- GitLab