Skip to content
Snippets Groups Projects
Commit 6f74d1f3 authored by Beth Davies's avatar Beth Davies
Browse files

Merge branch...

Merge branch '252-as-a-user-i-want-the-option-to-log-out-of-my-account-so-that-my-account-remains-secure' into 'release/Sprint-4'

Resolve "As a user I want the option to log out of my account, so that my account remains secure."

See merge request c24108486/team-11-polish-community-group!56
parents e9251e12 2da2fb6f
No related branches found
No related tags found
No related merge requests found
...@@ -27,8 +27,7 @@ repositories { ...@@ -27,8 +27,7 @@ repositories {
dependencies { dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' // Thymeleaf dependency implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' // Thymeleaf dependency
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6:3.1.2.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' // Thymeleaf dependency
implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-json' implementation 'org.springframework.boot:spring-boot-starter-json'
......
...@@ -14,6 +14,7 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException; ...@@ -14,6 +14,7 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.provisioning.InMemoryUserDetailsManager; import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.SecurityFilterChain;
import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfiguration;
import org.thymeleaf.extras.springsecurity6.dialect.SpringSecurityDialect;
import polish_community_group_11.polish_community.register.models.User; import polish_community_group_11.polish_community.register.models.User;
import polish_community_group_11.polish_community.register.services.UserService; import polish_community_group_11.polish_community.register.services.UserService;
import polish_community_group_11.polish_community.register.models.Role; import polish_community_group_11.polish_community.register.models.Role;
...@@ -74,22 +75,10 @@ public class WebSecurityConfig { ...@@ -74,22 +75,10 @@ public class WebSecurityConfig {
return http.build(); return http.build();
} }
@Bean
//Use in memory userDetailsManager to store & access login details public SpringSecurityDialect springSecurityDialect() {
// @Bean return new SpringSecurityDialect();
// public UserDetailsService userDetailsService() { }
// UserDetails user =
// User.withDefaultPasswordEncoder()
// .username("user@example.com") //use email as username
// .password("password")
// .roles("USER")
// .build();
//
// //can extend create more users here when needed (admin, super-admin etc)
//
// return new InMemoryUserDetailsManager(user);
// }
//}
@Bean @Bean
public UserDetailsService userDetailsService() { public UserDetailsService userDetailsService() {
......
...@@ -130,7 +130,7 @@ button:hover { ...@@ -130,7 +130,7 @@ button:hover {
} }
#eventsTile { #eventsTile {
background: linear-gradient(135deg, #FF7EB3, #FF758C); background: linear-gradient(135deg, yellowgreen, #006400);
color: white; color: white;
} }
......
...@@ -216,4 +216,39 @@ nav.sidebar { ...@@ -216,4 +216,39 @@ nav.sidebar {
.navText { .navText {
font-size: 14px; font-size: 14px;
font-weight: 500; font-weight: 500;
} }
\ No newline at end of file
/* ACCOUNT OPTIONS STYLING */
/* Dropdown styles */
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #f1f1f1;
}
.dropdown:hover .dropdown-content {
display: block;
}
/* ACCOUNT OPTIONS STYLING END */
\ No newline at end of file
* { * {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif font-family: "inter", sans-serif;
} }
form { form {
justify-items: end; justify-items: baseline;
padding: 10px; padding: 30px;
max-width: max-content; max-width: max-content;
width: 300px;
box-sizing: border-box; box-sizing: border-box;
margin-top: 15px; margin: 50px auto;
background-color: #e3afbc; /*margin-top: 15px;*/
border: 1px solid #ccc; background-color: var(--secondary-color);
border: 1px solid var(--border-color);
border-radius: 5px; border-radius: 5px;
} }
input { input[type="email"], input[type="password"]{
background-color: #e3e2df; background-color: var(--background-color);
border: 1px solid #ccc; border: 1px solid var(--border-color);
border-radius: 5px; border-radius: 5px;
padding: 10px 15px;
width: 80%;
margin-bottom: 10px;
}
input[type="submit"] {
background-color: var(--primary-color);
color: var(--alternate-text);
cursor: pointer;
transition: background-color 0.3s ease;
}
input[type="submit"]:hover {
background-color: #555;
} }
\ No newline at end of file
document.addEventListener('DOMContentLoaded', function() {
const accountOptions = document.getElementById('account-options');
const dropdownContent = document.getElementsByClassName('dropdown-content');
accountOptions.addEventListener('click', function (e) {
[...dropdownContent].forEach(dropdown => {
dropdown.style.display = dropdown.style.display ===
'block' ? 'none' : 'block'
});
});
//hide dropdown when user clicks outside of element
document.addEventListener('click', function(e) {
if (!accountOptions.contains(e.target)) {
[...dropdownContent].style.display = 'none';
}
});
});
\ No newline at end of file
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
<h1 data-translate-key="home.join_community">Join Our Thriving Community Today!</h1> <h1 data-translate-key="home.join_community">Join Our Thriving Community Today!</h1>
<p data-translate-key="home.tagline">Connect with like-minded individuals, share your ideas, and be part of something amazing</p> <p data-translate-key="home.tagline">Connect with like-minded individuals, share your ideas, and be part of something amazing</p>
<button data-translate-key="home.get_started">Get Started</button> <a th:href="@{/register}"><button data-translate-key="home.get_started">Get Started</button></a>
</section> </section>
......
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<html xmlns:th="http://www.thymeleaf.org" <html xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"> xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity6">
<head> <head>
<meta name="viewport" CHARSET="UTF-8" content="width=device-width, initial-scale=1"> <meta name="viewport" CHARSET="UTF-8" content="width=device-width, initial-scale=1">
...@@ -68,14 +70,28 @@ ...@@ -68,14 +70,28 @@
</div> </div>
<!-- Profile --> <!-- Profile -->
<a th:href="@{/profile}" class="navLink"> <div id="account-options">
<img src="/assets/navbarImages/profile.png" class="navIcons"><span class="navText" <div sec:authorize="isAnonymous()">
data-translate-key="navbar.profile">Profile</span> <img src="/assets/navbarImages/profile.png" class="navIcons anonymous">
</a> <span class="navText">Sign in</span>
</div> <div class="dropdown-content">
</nav> <a class="dropdown-nav-link" th:href="@{/login}">Login</a>
</section> <a class="dropdown-nav-link" th:href="@{/register}">Sign up</a>
</header> </div>
</div>
<div sec:authorize="isAuthenticated()">
<img src="/assets/navbarImages/profile.png" class="navIcons authenticated">
<span class="navText"data-translate-key="navbar.profile">Profile</span>
<div class="dropdown-content">
<a class="navLink" th:href="@{/profile}">View profile</a>
<a class="navLink" th:href="@{/logout}">Logout</a>
</div>
</div>
</div>
</nav>
</section>
</header>
<div class="mainBody"> <div class="mainBody">
<main layout:fragment="content" class="content"></main> <main layout:fragment="content" class="content"></main>
...@@ -115,5 +131,6 @@ ...@@ -115,5 +131,6 @@
</footer> </footer>
<script src="/js/layout/layout.js" defer></script> <script src="/js/layout/layout.js" defer></script>
<script th:replace="~{comments/commentFragment::commentScript}"></script> <script th:replace="~{comments/commentFragment::commentScript}"></script>
<script src="/js/layout/accountDropdown.js"></script>
</body> </body>
</html> </html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment