diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..3d869be
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
new file mode 100644
index 0000000..1cca0ec
--- /dev/null
+++ b/.idea/dataSources.xml
@@ -0,0 +1,19 @@
+
+
+
+
+ mysql.8
+ true
+ true
+ $PROJECT_DIR$/src/main/resources/application.properties
+ com.mysql.cj.jdbc.Driver
+ jdbc:mysql://localhost:3306/login_system
+
+
+
+
+
+ $ProjectFileDir$
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..63e9001
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..712ab9d
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..aacacf5
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index fafece6..9345851 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,11 +1,11 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
org.springframework.boot
spring-boot-starter-parent
- 3.0.0
+ 3.2.4
com.example
@@ -25,17 +25,23 @@
org.springframework.boot
spring-boot-starter-thymeleaf
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
- spring-boot-starter-validation
+ spring-boot-devtools
+ runtime
+ true
- mysql
- mysql-connector-java
+ com.mysql
+ mysql-connector-j
runtime
@@ -52,8 +58,12 @@
org.springframework.boot
spring-boot-starter-security
+
+ org.springframework.security
+ spring-security-test
+ test
+
-
@@ -70,4 +80,4 @@
-
+
\ No newline at end of file
diff --git a/src/main/java/com/example/registrationlogindemo/config/SpringSecurity.java b/src/main/java/com/example/registrationlogindemo/config/SpringSecurity.java
index 83bc063..07fe26e 100644
--- a/src/main/java/com/example/registrationlogindemo/config/SpringSecurity.java
+++ b/src/main/java/com/example/registrationlogindemo/config/SpringSecurity.java
@@ -6,6 +6,7 @@
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
@@ -26,11 +27,11 @@ public static PasswordEncoder passwordEncoder(){
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
- http.csrf().disable()
+ http.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests((authorize) ->
authorize.requestMatchers("/register/**").permitAll()
- .requestMatchers("/index").permitAll()
- .requestMatchers("/users").hasRole("ADMIN")
+ .requestMatchers("/").permitAll()
+ .requestMatchers("/users").hasAuthority("ROLE_ADMIN")
).formLogin(
form -> form
.loginPage("/login")
diff --git a/src/main/java/com/example/registrationlogindemo/controller/AuthController.java b/src/main/java/com/example/registrationlogindemo/controller/AuthController.java
index 09dbdd7..980606d 100644
--- a/src/main/java/com/example/registrationlogindemo/controller/AuthController.java
+++ b/src/main/java/com/example/registrationlogindemo/controller/AuthController.java
@@ -22,7 +22,7 @@ public AuthController(UserService userService) {
this.userService = userService;
}
- @GetMapping("index")
+ @GetMapping("/")
public String home(){
return "index";
}
diff --git a/target/classes/application.properties b/target/classes/application.properties
new file mode 100644
index 0000000..5a0cdba
--- /dev/null
+++ b/target/classes/application.properties
@@ -0,0 +1,6 @@
+spring.datasource.url=jdbc:mysql://localhost:3306/login_system
+spring.datasource.username=root
+spring.datasource.password=23042002
+
+spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
+spring.jpa.hibernate.ddl-auto=update
diff --git a/target/classes/com/example/registrationlogindemo/RegistrationLoginDemoApplication.class b/target/classes/com/example/registrationlogindemo/RegistrationLoginDemoApplication.class
new file mode 100644
index 0000000..afb2125
Binary files /dev/null and b/target/classes/com/example/registrationlogindemo/RegistrationLoginDemoApplication.class differ
diff --git a/target/classes/com/example/registrationlogindemo/config/SpringSecurity.class b/target/classes/com/example/registrationlogindemo/config/SpringSecurity.class
new file mode 100644
index 0000000..f8eedb5
Binary files /dev/null and b/target/classes/com/example/registrationlogindemo/config/SpringSecurity.class differ
diff --git a/target/classes/com/example/registrationlogindemo/controller/AuthController.class b/target/classes/com/example/registrationlogindemo/controller/AuthController.class
new file mode 100644
index 0000000..b8179a6
Binary files /dev/null and b/target/classes/com/example/registrationlogindemo/controller/AuthController.class differ
diff --git a/target/classes/com/example/registrationlogindemo/dto/UserDto.class b/target/classes/com/example/registrationlogindemo/dto/UserDto.class
new file mode 100644
index 0000000..1d777d2
Binary files /dev/null and b/target/classes/com/example/registrationlogindemo/dto/UserDto.class differ
diff --git a/target/classes/com/example/registrationlogindemo/entity/Role.class b/target/classes/com/example/registrationlogindemo/entity/Role.class
new file mode 100644
index 0000000..72536a5
Binary files /dev/null and b/target/classes/com/example/registrationlogindemo/entity/Role.class differ
diff --git a/target/classes/com/example/registrationlogindemo/entity/User.class b/target/classes/com/example/registrationlogindemo/entity/User.class
new file mode 100644
index 0000000..99c1f8f
Binary files /dev/null and b/target/classes/com/example/registrationlogindemo/entity/User.class differ
diff --git a/target/classes/com/example/registrationlogindemo/repository/RoleRepository.class b/target/classes/com/example/registrationlogindemo/repository/RoleRepository.class
new file mode 100644
index 0000000..81a0ca0
Binary files /dev/null and b/target/classes/com/example/registrationlogindemo/repository/RoleRepository.class differ
diff --git a/target/classes/com/example/registrationlogindemo/repository/UserRepository.class b/target/classes/com/example/registrationlogindemo/repository/UserRepository.class
new file mode 100644
index 0000000..ca7d48b
Binary files /dev/null and b/target/classes/com/example/registrationlogindemo/repository/UserRepository.class differ
diff --git a/target/classes/com/example/registrationlogindemo/security/CustomUserDetailsService.class b/target/classes/com/example/registrationlogindemo/security/CustomUserDetailsService.class
new file mode 100644
index 0000000..83a2fdd
Binary files /dev/null and b/target/classes/com/example/registrationlogindemo/security/CustomUserDetailsService.class differ
diff --git a/target/classes/com/example/registrationlogindemo/service/UserService.class b/target/classes/com/example/registrationlogindemo/service/UserService.class
new file mode 100644
index 0000000..ff18757
Binary files /dev/null and b/target/classes/com/example/registrationlogindemo/service/UserService.class differ
diff --git a/target/classes/com/example/registrationlogindemo/service/impl/UserServiceImpl.class b/target/classes/com/example/registrationlogindemo/service/impl/UserServiceImpl.class
new file mode 100644
index 0000000..8cb10bc
Binary files /dev/null and b/target/classes/com/example/registrationlogindemo/service/impl/UserServiceImpl.class differ
diff --git a/target/classes/templates/index.html b/target/classes/templates/index.html
new file mode 100644
index 0000000..5aa4e50
--- /dev/null
+++ b/target/classes/templates/index.html
@@ -0,0 +1,38 @@
+
+
+
+
+ Registration and Login System
+
+
+
+
+
+
+
Welcome to Registration and Login System
+
+
+
+
\ No newline at end of file
diff --git a/target/classes/templates/login.html b/target/classes/templates/login.html
new file mode 100644
index 0000000..b3af972
--- /dev/null
+++ b/target/classes/templates/login.html
@@ -0,0 +1,76 @@
+
+
+
+
+ Registration and Login System
+
+
+
+
+
+
+
+
+
+
+
+
Invalid Email and Password.
+
+
+
You have been logged out.
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/target/classes/templates/register.html b/target/classes/templates/register.html
new file mode 100644
index 0000000..5f7d590
--- /dev/null
+++ b/target/classes/templates/register.html
@@ -0,0 +1,101 @@
+
+
+
+
+ Registration and Login System
+
+
+
+
+
+
+
+
+
+
+
+
You've successfully registered
+ to our app!
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/target/classes/templates/users.html b/target/classes/templates/users.html
new file mode 100644
index 0000000..e031399
--- /dev/null
+++ b/target/classes/templates/users.html
@@ -0,0 +1,54 @@
+
+
+
+
+ Registration and Login System
+
+
+
+
+
+
+
Registered Users
+
+
+
+
+ | First Name |
+ Last Name |
+ Email |
+
+
+
+
+ |
+ |
+ |
+
+
+
+
+
+
\ No newline at end of file