diff --git a/src/main/java/com/example/proyectofinal/configuration/CustomAuthenticacionHandler.java b/src/main/java/com/example/proyectofinal/configuration/CustomAuthenticacionHandler.java index 4d135b0..7104af4 100644 --- a/src/main/java/com/example/proyectofinal/configuration/CustomAuthenticacionHandler.java +++ b/src/main/java/com/example/proyectofinal/configuration/CustomAuthenticacionHandler.java @@ -8,7 +8,9 @@ import org.springframework.security.web.authentication.SimpleUrlAuthenticationSu import java.io.IOException; public class CustomAuthenticacionHandler extends SimpleUrlAuthenticationSuccessHandler { - + /** + * This method redirects to buscador after validation + */ @Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { diff --git a/src/main/java/com/example/proyectofinal/configuration/PasswordEcodingConf.java b/src/main/java/com/example/proyectofinal/configuration/PasswordEcodingConf.java index 3b166e9..a748a18 100644 --- a/src/main/java/com/example/proyectofinal/configuration/PasswordEcodingConf.java +++ b/src/main/java/com/example/proyectofinal/configuration/PasswordEcodingConf.java @@ -7,6 +7,9 @@ import org.springframework.security.crypto.password.PasswordEncoder; @Configuration public class PasswordEcodingConf { + /** + * This method encrypts the password with BCrypt + */ @Bean public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); diff --git a/src/main/java/com/example/proyectofinal/configuration/SecurityConfig.java b/src/main/java/com/example/proyectofinal/configuration/SecurityConfig.java index 7459cac..013744a 100644 --- a/src/main/java/com/example/proyectofinal/configuration/SecurityConfig.java +++ b/src/main/java/com/example/proyectofinal/configuration/SecurityConfig.java @@ -21,19 +21,23 @@ public class SecurityConfig{ private static final Logger logger = LoggerFactory.getLogger(SecurityConfig.class); @Autowired private JdbcTemplate jdbcTemplate; - @Autowired - private UsuarioService usuarioService; - @Autowired - private RolRepository rolService; - - @Autowired private CustomAuth customAuth; + /** + * This method is used to configure the global AuthenticationManager. + */ @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth.authenticationProvider(customAuth); } + /** + * This bean is used to configure the security filter chain. + * The security filter chain is responsible for handling all security related tasks. + * It is the most important part of the Spring Security configuration. + * It is responsible for authenticating the user, authorizing the user, and handling the session. + */ + @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { initializeAutoridadAndRolTables(); @@ -67,6 +71,11 @@ public class SecurityConfig{ return new CustomAuthenticacionHandler(); } + /** + * This method is in charge of create the default roles, authorities and admin user. + * also uses method to instert some other information in the database. Skill, Sector, Family and Cycle + */ + private void initializeAutoridadAndRolTables() { // Check if the autoridad table is empty Integer autoridadCount = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM autoridad", Integer.class); diff --git a/src/main/java/com/example/proyectofinal/controllers/modelControllers/AlumnoController.java b/src/main/java/com/example/proyectofinal/controllers/modelControllers/AlumnoController.java index b555045..96beacd 100644 --- a/src/main/java/com/example/proyectofinal/controllers/modelControllers/AlumnoController.java +++ b/src/main/java/com/example/proyectofinal/controllers/modelControllers/AlumnoController.java @@ -6,7 +6,6 @@ import com.example.proyectofinal.servicios.empresa.AlumnoService; import com.example.proyectofinal.servicios.empresa.CicloService; import com.example.proyectofinal.servicios.empresa.SkillService; import com.example.proyectofinal.servicios.user.UsuarioService; -import jakarta.annotation.security.RolesAllowed; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -74,7 +73,6 @@ public class AlumnoController { if(testIfExist != null){ return new ResponseEntity<>("El alumno ya existe", HttpStatus.BAD_REQUEST); } - String password = "1234"; StringBuilder nombreUsuarioBuilder = new StringBuilder(); nombreUsuarioBuilder.append(alumno.getNombre().toLowerCase()); @@ -142,10 +140,6 @@ public class AlumnoController { nombreUsuarioBuilder.append(alumno.getApellido2().toLowerCase()); } String nombreUsuario = nombreUsuarioBuilder.toString(); - String nia = alumno.getNia(); - String firstThreeLetters = nia.substring(0, 3); - String nombreLogIn="alu." +alumno.getNombre()+firstThreeLetters; - usuario.setNombreLogIn(nombreLogIn); usuario.setNombreUsuario(nombreUsuario); usuarioService.saveUser(usuario); diff --git a/src/main/java/com/example/proyectofinal/servicios/MailService.java b/src/main/java/com/example/proyectofinal/servicios/MailService.java index 6369a49..479505f 100644 --- a/src/main/java/com/example/proyectofinal/servicios/MailService.java +++ b/src/main/java/com/example/proyectofinal/servicios/MailService.java @@ -33,7 +33,7 @@ public class MailService { helper.setTo("empresas@ies.edu.es"); helper.setText(textMessage, true); helper.setSubject(subject); - helper.setCc("victorsash96@gmail.com"); + //helper.setCc(email); emailSender.send(message); send = true; LOGGER.info("Mail sent!"); diff --git a/src/main/java/com/example/proyectofinal/servicios/empresa/AlumnoService.java b/src/main/java/com/example/proyectofinal/servicios/empresa/AlumnoService.java index 00b9776..d38be5c 100644 --- a/src/main/java/com/example/proyectofinal/servicios/empresa/AlumnoService.java +++ b/src/main/java/com/example/proyectofinal/servicios/empresa/AlumnoService.java @@ -28,15 +28,11 @@ public class AlumnoService implements IAlumno{ if(secondaryOption.equalsIgnoreCase("Todo")){ return findAllPaginated(pageNum, size, sortField, sortDir); }else if (secondaryOption.equals("Apellido")) { - return alumnoRepository.findAlumnoByApellido(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending())); + return alumnoRepository.findAlumnoByApellidos(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending())); } else if(secondaryOption.equals("Nombre")) { return alumnoRepository.findAlumnoByNombre(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending())); }else if(secondaryOption.equals("Keywords")) { return alumnoRepository.findAlumnoByKeywords(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending())); - }else if(secondaryOption.equals("Nia")) { - return alumnoRepository.findAlumnoByNia(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending())); - }else if(secondaryOption.equals("Dni")) { - return alumnoRepository.findAlumnoByDni(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending())); }else if(secondaryOption.equals("Ciclo")) { return alumnoRepository.findAlumnoByCiclo(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending())); } else { @@ -49,8 +45,6 @@ public class AlumnoService implements IAlumno{ return alumnoRepository.findAll(); } - - @Override public Alumno findById(Long id) { return alumnoRepository.findById(id).orElse(null); diff --git a/src/main/resources/static/style.css b/src/main/resources/static/style.css index 98354c2..e4fe930 100644 --- a/src/main/resources/static/style.css +++ b/src/main/resources/static/style.css @@ -113,10 +113,14 @@ body { white-space: normal; text-align: center; } - +.toolbar { + display: flex; + align-items: center; + justify-content: space-between; +} i.fas.fa-arrow-left { z-index: 1; - pointer-events: auto; /* Add this line */ + pointer-events: auto; } .button-group { display: flex; @@ -164,7 +168,6 @@ html, body { #create-icon { color: green; font-size: 20px; - margin-left: 10px; } .inactive { pointer-events: none; diff --git a/src/main/resources/templates/list/alumnos.html b/src/main/resources/templates/list/alumnos.html index c17dea0..5e061d1 100644 --- a/src/main/resources/templates/list/alumnos.html +++ b/src/main/resources/templates/list/alumnos.html @@ -30,11 +30,15 @@ - - -
- - +
+
+ + +
+
+ + +
diff --git a/src/main/resources/templates/list/ciclos.html b/src/main/resources/templates/list/ciclos.html index e5e0e7a..aea97c3 100644 --- a/src/main/resources/templates/list/ciclos.html +++ b/src/main/resources/templates/list/ciclos.html @@ -24,13 +24,16 @@
- - -
- - +
+
+ + +
+
+ + +
-
diff --git a/src/main/resources/templates/list/contactos.html b/src/main/resources/templates/list/contactos.html index 527acdb..071e6de 100644 --- a/src/main/resources/templates/list/contactos.html +++ b/src/main/resources/templates/list/contactos.html @@ -24,12 +24,17 @@ - - -
- - +
+
+ + +
+
+ + +
+
diff --git a/src/main/resources/templates/list/empresas.html b/src/main/resources/templates/list/empresas.html index 59f33a3..1dcf763 100644 --- a/src/main/resources/templates/list/empresas.html +++ b/src/main/resources/templates/list/empresas.html @@ -27,11 +27,15 @@ - - -
- - +
+
+ + +
+
+ + +
diff --git a/src/main/resources/templates/list/familias.html b/src/main/resources/templates/list/familias.html index dbe4f6a..3d17238 100644 --- a/src/main/resources/templates/list/familias.html +++ b/src/main/resources/templates/list/familias.html @@ -22,13 +22,17 @@
- - - -
- - +
+
+ + +
+
+ + +
+
diff --git a/src/main/resources/templates/list/ofertas.html b/src/main/resources/templates/list/ofertas.html index 9a4c802..cc109cc 100644 --- a/src/main/resources/templates/list/ofertas.html +++ b/src/main/resources/templates/list/ofertas.html @@ -26,11 +26,15 @@ - - -
- - +
+
+ + +
+
+ + +
diff --git a/src/main/resources/templates/list/sectores.html b/src/main/resources/templates/list/sectores.html index 6c52cab..74e1ab4 100644 --- a/src/main/resources/templates/list/sectores.html +++ b/src/main/resources/templates/list/sectores.html @@ -24,11 +24,15 @@
- - -
- - +
+
+ + +
+
+ + +
diff --git a/src/main/resources/templates/list/skills.html b/src/main/resources/templates/list/skills.html index 41e8a77..5d7570c 100644 --- a/src/main/resources/templates/list/skills.html +++ b/src/main/resources/templates/list/skills.html @@ -15,10 +15,6 @@
-
- - -

Listado de Skills @@ -27,7 +23,16 @@

- +
+
+ + +
+
+ + +
+
diff --git a/src/main/resources/templates/list/sucursales.html b/src/main/resources/templates/list/sucursales.html index 9560e40..186f6d6 100644 --- a/src/main/resources/templates/list/sucursales.html +++ b/src/main/resources/templates/list/sucursales.html @@ -15,10 +15,6 @@
-
- - -

Listado de Ofertas @@ -27,7 +23,16 @@

- +
+
+ + +
+
+ + +
+
diff --git a/src/main/resources/templates/user/update_alu.html b/src/main/resources/templates/user/update_alu.html index f12107e..75fa477 100644 --- a/src/main/resources/templates/user/update_alu.html +++ b/src/main/resources/templates/user/update_alu.html @@ -75,7 +75,7 @@
- +