Skip to content

Commit 9dba345

Browse files
Merge pull request #17 from Csaba79-coder/feature-refactor-login-signup-pages-vasile
update the view of the registration
2 parents 2c3f0aa + 5470ffd commit 9dba345

File tree

8 files changed

+67
-120
lines changed

8 files changed

+67
-120
lines changed

pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,16 @@
110110
<scope>test</scope>
111111
</dependency>
112112

113+
113114
<!--<dependency>
114115
<groupId>org.springframework.security</groupId>
115116
<artifactId>spring-security-test</artifactId>
116117
<scope>test</scope>
117118
</dependency>-->
118119
</dependencies>
119120

121+
122+
120123
<build>
121124
<plugins>
122125
<plugin>

src/main/java/com/csaba79coder/littersnap/view/RegistrationViewController.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.csaba79coder.littersnap.model.user.dto.UserRegistrationModel;
44
import com.csaba79coder.littersnap.model.user.service.UserService;
5-
import jakarta.validation.Valid;
65
import lombok.RequiredArgsConstructor;
76
import org.springframework.stereotype.Controller;
87
import org.springframework.ui.Model;
@@ -21,15 +20,18 @@ public class RegistrationViewController {
2120

2221
@GetMapping("/registration")
2322
public String showRegistrationForm(Model model) {
24-
model.addAttribute("userRegistrationModel", new UserRegistrationModel());
25-
return "registration";
23+
UserRegistrationModel tempModel = new UserRegistrationModel();
24+
model.addAttribute("userRegistrationModel", tempModel );
25+
model.addAttribute("view","signUp_form");
26+
return "index";
2627
}
2728

2829
@PostMapping("/registration")
29-
public String registerUser(@ModelAttribute("userRegistrationModel") @Valid UserRegistrationModel registrationModel,
30+
public String registerUser(@ModelAttribute("userRegistrationModel") UserRegistrationModel registrationModel,
3031
BindingResult bindingResult) {
32+
3133
if (bindingResult.hasErrors()) {
32-
return "registration";
34+
return "signUp_form";
3335
}
3436

3537
// Create a User object from the registration model and save it using the UserService
@@ -38,3 +40,5 @@ public String registerUser(@ModelAttribute("userRegistrationModel") @Valid UserR
3840
return "redirect:/index"; // Redirect to the index page after successful registration
3941
}
4042
}
43+
44+

src/main/resources/static/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ body {
2424
z-index: 999;
2525
}
2626

27+
/*SignUp form*/
28+
.signup-form-container{
29+
max-width: 600px;
30+
}
2731
/*Image redendering size controll*/
2832
.image-container {
2933
max-width: 350px; /* Set the maximum width for the image container */

src/main/resources/templates/index.html

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,27 @@
2828
data-bs-target="#signInModal">
2929
SignIn
3030
</button>
31-
<button class="btn btn-warning btn-sm btn-block m-1" data-bs-toggle="modal"
32-
data-bs-target="#signUpModal">
33-
SignUp
34-
</button>
31+
<a th:href="@{/thy/security/registration}" class="btn btn-warning btn-sm btn-block m-1" >SignUp</a>
32+
</div>
33+
</div>
34+
35+
<div th:replace="~{signIn_form}"></div>
36+
<!-- Modal -->
37+
<!-- Container for dynamic content -->
38+
<div class="container">
39+
<div class="row justify-content-center">
40+
<div class="col-12 col-md-6">
41+
<!-- Dynamic content placeholder -->
42+
<div th:if="~{${view}}" class="row m-4">
43+
<div class="col">
44+
<!-- Dynamic Content Placeholder -->
45+
<div th:insert="~{${view}}"></div>
46+
</div>
47+
</div>
48+
</div>
3549
</div>
3650
</div>
3751

38-
<div th:replace="~{signIn_form}"></div>
39-
<div th:replace="~{signUp_form}"></div>
4052

4153
<!-- Middle Part -->
4254
<div class="row justify-content-center align-items-center min-vh-100">

src/main/resources/templates/registration.html

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/main/resources/templates/signIn_form.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ <h5 class="modal-title" id="signInModalLabel">Sign In</h5>
2424
<a th:href="@{/thy/auth/admin/litters}" class="btn btn-primary mt-3">SignIn</a>
2525
</form>
2626
<div class="text-center mt-3">
27-
<p>Don't have an account? <a href="#signUpModal" data-bs-toggle="modal"
27+
<p>Don't have an account? <a th:href="@{/thy/security/registration}" data-bs-toggle="modal"
2828
data-bs-dismiss="modal">Sign Up</a></p>
2929
</div>
3030
</div>
Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
1-
<div class="modal fade" id="signUpModal" tabindex="-1" aria-labelledby="signUpModalLabel" aria-hidden="true">
2-
<div class="modal-dialog">
3-
<div class="modal-content">
4-
<!-- Modal header -->
5-
<div class="modal-header">
6-
<h5 class="modal-title" id="signUpModalLabel">Sign Up</h5>
7-
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
1+
<div class="container mt-4 bg-white ">
2+
<div class="row">
3+
<div class="col">
4+
<div class="my-3">
5+
<h3>Registration Form</h3>
6+
<p>Please fill out the following information:</p>
87
</div>
8+
<form th:action="@{/thy/security/registration}" method="post" th:object="${userRegistrationModel}">
9+
<div class="form-group">
10+
<label for="email">Email</label>
11+
<input type="email" class="form-control" id="email" name="email" required>
12+
<span th:if="${#fields.hasErrors('email')}" th:errors="*{email}"></span>
13+
</div>
14+
<div class="form-group">
15+
<label for="firstName">First Name</label>
16+
<input type="text" class="form-control" id="firstName" name="firstName" required>
17+
<span th:if="${#fields.hasErrors('firstName')}" th:errors="*{firstName}"></span>
18+
</div>
19+
<div class="form-group">
20+
<label for="password">Password</label>
21+
<input type="password" class="form-control" id="password" name="password" required>
22+
<span th:if="${#fields.hasErrors('password')}" th:errors="*{password}"></span>
23+
</div>
24+
<div class="form-group">
25+
<label for="confirmPassword">Confirm Password</label>
26+
<input type="password" class="form-control" id="confirmPassword" name="confirmPassword" required>
27+
<span th:if="${#fields.hasErrors('passwordConfirmation')}" th:errors="*{passwordConfirmation}"></span>
28+
</div>
29+
<button type="submit" class="btn btn-primary m-3">Sign Up</button>
30+
31+
</form>
932

10-
<!-- Modal body -->
11-
<div class="modal-body">
12-
<div class="d-flex justify-content-center">
13-
<div class="sign-up-container">
14-
<form th:action="@{/thy/security/signup}" method="post">
15-
<div class="form-group">
16-
<label for="email">Email</label>
17-
<input type="email" class="form-control" id="email" name="email" required>
18-
</div>
19-
<div class="form-group">
20-
<label for="firstName">First Name</label>
21-
<input type="text" class="form-control" id="firstName" name="firstName" required>
22-
</div>
23-
<div class="form-group">
24-
<label for="password">Password</label>
25-
<input type="password" class="form-control" id="password" name="password" required>
26-
</div>
27-
<div class="form-group">
28-
<label for="confirmPassword">Confirm Password</label>
29-
<input type="password" class="form-control" id="confirmPassword" name="confirmPassword" required>
30-
</div>
31-
<button type="submit" class="btn btn-primary mt-3">Sign Up</button>
32-
</form>
3333

34-
</div>
35-
</div>
36-
</div>
3734
</div>
3835
</div>
3936
</div>
37+
38+

src/main/resources/templates/welcome.html

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -55,49 +55,6 @@
5555
</div>
5656
</nav>
5757

58-
59-
60-
61-
62-
63-
64-
<!-- Hamburger button-->
65-
<!-- <div class="row justify-content-end m-3">-->
66-
<!-- <div class="btn-group col-12 col-md-4 col-lg-2 fixed-buttons">-->
67-
<!-- <div class="d-flex align-items-center">-->
68-
<!-- <div class="me-2">Welcome, <span th:text="Csaba"></span></div>-->
69-
<!-- <div class="dropdown">-->
70-
<!-- <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton"-->
71-
<!-- data-bs-toggle="dropdown" aria-expanded="false">-->
72-
<!-- <i class="fas fa-bars"></i>-->
73-
<!-- </button>-->
74-
<!-- <ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">-->
75-
<!-- <li><a class="dropdown-item" >Logout</a></li>-->
76-
<!-- <li><a class="dropdown-item" th:href="@{/thy/litter}">View Reports</a></li>-->
77-
<!-- <li><a class="dropdown-item" th:href="@{/thy/users}">User List</a></li>-->
78-
<!-- </ul>-->
79-
<!-- </div>-->
80-
<!-- </div>-->
81-
<!-- </div>-->
82-
<!-- </div>-->
83-
84-
85-
86-
87-
<!--Getting the input and populating the addlitter-->
88-
<!-- <div class="row justify-content-center mt-10">-->
89-
<!-- <div class="col-12 col-md-7 col-lg-6">-->
90-
<!-- <form th:action="@{/thy/litter/create}" method="get" class="d-flex">-->
91-
<!-- <div class="form-group flex-grow-1">-->
92-
<!-- <input type="text" class="form-control" id="cityInput" name="city"-->
93-
<!-- placeholder="Enter the city..." required>-->
94-
<!-- </div>-->
95-
<!-- <button type="submit" class="btn btn-primary btn-sm-md">Add Litter</button>-->
96-
<!-- </form>-->
97-
<!-- </div>-->
98-
<!-- </div>-->
99-
100-
10158
<!-- Container for dynamic content -->
10259
<div class="container mt-4 bg-white">
10360
<div class="row">

0 commit comments

Comments
 (0)