From 096efe586693541940d1d381a5fb2b518ee3fc1f Mon Sep 17 00:00:00 2001 From: jon ander Date: Tue, 25 Mar 2025 19:21:12 +0100 Subject: [PATCH] Refactor HTML structure and update security configuration for role-based access --- .../GestionInventario/SecurityConfig.java | 3 +- src/main/resources/application.properties | 6 ---- src/main/resources/static/css/style.css | 27 ++++++-------- src/main/resources/templates/Home.html | 26 ++++++++++---- src/main/resources/templates/Login.html | 2 +- src/main/resources/templates/Register.html | 35 ++++++++++++------- 6 files changed, 54 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/ieslamar/GestionInventario/SecurityConfig.java b/src/main/java/com/ieslamar/GestionInventario/SecurityConfig.java index b9a9ac2..561a20f 100644 --- a/src/main/java/com/ieslamar/GestionInventario/SecurityConfig.java +++ b/src/main/java/com/ieslamar/GestionInventario/SecurityConfig.java @@ -27,7 +27,8 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti .requestMatchers("/css/**", "/js/**", "/images/**").permitAll() // 🔹 Permitir acceso a CSS, JS e imágenes .requestMatchers("/admin/**").hasRole("ADMIN") .requestMatchers("/user/**").hasAnyRole("USER", "ADMIN") - .requestMatchers("/", "/login", "/register").permitAll() + .requestMatchers("/register").hasRole("ADMIN") + .requestMatchers("/", "/login").permitAll() .anyRequest().authenticated() ) .formLogin(login -> login diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 0adb9bc..fb96634 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -17,10 +17,4 @@ spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect spring.jpa.hibernate.ddl-auto=update -# Para inicializar datos en la base de datos (opcional) -spring.sql.init.mode=always -spring.security.user.name=admin -spring.security.user.password=admin123 -spring.security.user.roles=ADMIN - diff --git a/src/main/resources/static/css/style.css b/src/main/resources/static/css/style.css index 565ed67..b64c018 100644 --- a/src/main/resources/static/css/style.css +++ b/src/main/resources/static/css/style.css @@ -17,7 +17,16 @@ p { margin-bottom: 20px; } -form { +.register_form{ + background-color: #fff; + padding: 20px; + border-radius: 8px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + width: 100%; + max-width: 400px; + box-sizing: border-box; +} +.container1{ background-color: #fff; padding: 20px; border-radius: 8px; @@ -26,7 +35,6 @@ form { max-width: 400px; box-sizing: border-box; } - .input-group { margin-bottom: 15px; } @@ -57,21 +65,6 @@ button { button:hover { background-color: #0056b3; } - -#button1 { - width: 100%; - padding: 10px; - background-color: #007bff; - color: #fff; - border: none; - border-radius: 4px; - cursor: pointer; - -} -#button1:hover{ - background-color: #0056b3; -} - #message { margin-top: 15px; text-align: center; diff --git a/src/main/resources/templates/Home.html b/src/main/resources/templates/Home.html index e910b27..190cda5 100644 --- a/src/main/resources/templates/Home.html +++ b/src/main/resources/templates/Home.html @@ -1,15 +1,27 @@ - + Home + +

- -
- - - -
+
+ +
+ + + +
+ +
+
+
+ + + +
+
\ No newline at end of file diff --git a/src/main/resources/templates/Login.html b/src/main/resources/templates/Login.html index 4361726..a7a6caf 100644 --- a/src/main/resources/templates/Login.html +++ b/src/main/resources/templates/Login.html @@ -6,7 +6,7 @@ -
+

Iniciar Sesión

diff --git a/src/main/resources/templates/Register.html b/src/main/resources/templates/Register.html index 4cce4ff..cb2c316 100644 --- a/src/main/resources/templates/Register.html +++ b/src/main/resources/templates/Register.html @@ -2,21 +2,30 @@ Registro +

Registro

- - - - - - - - - -
+
+
+ + + +
+
+ + +
+
+ + +
+
+ +
+