This commit is contained in:
kaipher7
2026-03-11 11:10:12 -06:00
15 changed files with 53 additions and 11 deletions
@@ -2,8 +2,10 @@ package com.example.demo.config;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
@Configuration @Configuration
public class SecurityConfig { public class SecurityConfig {
@@ -11,4 +13,20 @@ public class SecurityConfig {
public PasswordEncoder passwordEncoder() { public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder(); return new BCryptPasswordEncoder();
} }
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests(auth -> auth
.requestMatchers("/login", "/css/**").permitAll()
.anyRequest().authenticated()
)
.formLogin(form -> form
.loginPage("/login")
// .defaultSuccessUrl("/", true)
.permitAll()
)
.logout(logout -> logout.permitAll());
return http.build();
}
} }
@@ -0,0 +1,20 @@
package com.example.demo.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class SiteController {
@GetMapping("/")
public String viewHomePage(Model model) {
//model.addAttribute("allemplist", employeeServiceImpl.getAllEmployee());
return "home";
}
@GetMapping("/login")
public String viewLoginPage(Model model) {
return "login";
}
}

Before

Width:  |  Height:  |  Size: 124 KiB

After

Width:  |  Height:  |  Size: 124 KiB

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 55 KiB

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Before

Width:  |  Height:  |  Size: 140 KiB

After

Width:  |  Height:  |  Size: 140 KiB

Before

Width:  |  Height:  |  Size: 140 KiB

After

Width:  |  Height:  |  Size: 140 KiB

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

@@ -3,14 +3,14 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Create Thyme Crunch Account</title> <title>Create Thyme Crunch Account</title>
<link rel="stylesheet" href="css/create-account.css"> <link rel="stylesheet" th:href="@{static/css/create-account.css}">
</head> </head>
<body> <body>
<header class="top-header"> <header class="top-header">
<img src="images/header_left.png" alt="Violin f-hole shape to the left of header." class="swirl"> <img src="static/images/header_left.png" alt="Violin f-hole shape to the left of header." class="swirl">
<h1 class="site-name">Thyme Crunch</h1> <h1 class="site-name">Thyme Crunch</h1>
<img src="images/header_right.png" alt="Violin f-hole shape to the right of header." class="swirl"> <img src="static/images/header_right.png" alt="Violin f-hole shape to the right of header." class="swirl">
</header> </header>
@@ -3,14 +3,14 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Thyme Crunch Home</title> <title>Thyme Crunch Home</title>
<link rel="stylesheet" href="css/home.css"> <link rel="stylesheet" th:href="@{/css/home.css}">
</head> </head>
<body> <body>
<header class="top-header"> <header class="top-header">
<img src="images/header_left.png" alt="Violin f-hole shape to the left of header." class="swirl"> <img src="static/images/header_left.png" alt="Violin f-hole shape to the left of header." class="swirl">
<h1 class="site-name">Thyme Crunch</h1> <h1 class="site-name">Thyme Crunch</h1>
<img src="images/header_right.png" alt="Violin f-hole shape to the right of header." class="swirl"> <img src="static/images/header_right.png" alt="Violin f-hole shape to the right of header." class="swirl">
</header> </header>
<div class="container"> <div class="container">
@@ -24,7 +24,7 @@
<li> <li>
<form action="/logout" method="post"> <form action="/logout" method="post">
<button type="submit" class="nav_icon"> <button type="submit" class="nav_icon">
<img src="images/logout_icon.png" alt="Log Out Icon"> <img src="static/images/logout_icon.png" alt="Log Out Icon">
</button> </button>
</li> </li>
</ul> </ul>
@@ -34,7 +34,7 @@
</nav> </nav>
<a href="#" target="_blank" class="create_icon"> <a href="#" target="_blank" class="create_icon">
<img src="images/create_icon.png" alt="Description of the icon"> <img src="static/images/create_icon.png" alt="Description of the icon">
</a> </a>
@@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Thyme Crunch Login</title> <title>Thyme Crunch Login</title>
<link rel="stylesheet" href="css/login.css"> <link rel="stylesheet" th:href="@{css/login.css}">
</head> </head>
<body> <body>
@@ -18,9 +18,13 @@
<main class="main-content"> <main class="main-content">
<div class="login-box"> <div class="login-box">
<h2>Log In</h2> <h2>Log In</h2>
<form action="/login" method="post"> <div th:if="${param.error}">
Invalid username and password.</div>
<div th:if="${param.logout}">
You have been logged out.</div>
<form th:action="@{/login}" method="post">
<label for="username">Username</label> <label for="username">Username</label>
<input type="text" id="user" name="user" required> <input type="text" id="username" name="username" required>
<label for="password">Password</label> <label for="password">Password</label>
<input type="password" id="password" name="password" required> <input type="password" id="password" name="password" required>