Skip to content

Commit 649b6e4

Browse files
committed
Fix Sign In (Ahora setea datos de nuevo usuario mediante @RequestParam)
1 parent 19cfb3a commit 649b6e4

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

backend/gamelink/src/main/java/urjc/gamelink/Controllers/GamelinkController.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,19 @@ public String signin(Model model){
309309
}
310310

311311
@PostMapping("/signin")
312-
public String signin(Model model, @RequestParam (required = true) Usero user, @RequestParam String password){
312+
public String signin(Model model, Usero user, @RequestParam (required = true) String name, @RequestParam String email,
313+
@RequestParam String password, @RequestParam String nick, @RequestParam String lastName){
313314

314-
if (user.getName().equals("") || user.getName() == null){
315+
if (name.equals("") || name == null){
315316
return "errorMessage";
316317
}
317318

318319
ArrayList<String> lista = new ArrayList<>();
319320
lista.add("USERO");
321+
user.setName(name);
322+
user.setEmail(email);
323+
user.setNick(nick);
324+
user.setLastName(lastName);
320325
user.setRoles(lista);
321326
user.setEncodedPassword(passwordEncoder.encode(password));
322327

backend/gamelink/src/main/java/urjc/gamelink/Service/dbInit.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public void init() throws IOException, URISyntaxException {
224224

225225
/* inserting users into the database */
226226

227-
Usero usr = new Usero("usera", "useraPepe", "Uno", "[email protected]");
227+
Usero usr = new Usero("user", "usuario", "usuarioLastname", "[email protected]");
228228
usr.setEncodedPassword(passwordEncoder.encode("123"));
229229
ArrayList<String> roles1 = new ArrayList<>();
230230
roles1.add("USERO");
@@ -241,7 +241,7 @@ public void init() throws IOException, URISyntaxException {
241241
usr2.setRoles(roles2);
242242
us.save(usr2);
243243

244-
Usero usr3 = new Usero("admin", "adminPepe", "Uno", "[email protected]");
244+
Usero usr3 = new Usero("admin", "adminName", "adminLastName", "[email protected]");
245245
usr3.setEncodedPassword(passwordEncoder.encode("123"));
246246
ArrayList<String> roles3 = new ArrayList<>();
247247
roles3.add("USERO");

backend/gamelink/src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ spring.mustache.suffix=.html
1010

1111
spring.datasource.url=jdbc:postgresql://localhost/gamelink
1212
spring.datasource.username=postgres
13-
spring.datasource.password=Universum3
13+
spring.datasource.password=password
1414
spring.jpa.hibernate.ddl-auto=create-drop
1515

1616
logging.level.org.springframework.security=DEBUG

backend/gamelink/src/main/resources/templates/signin.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ <h3 class="card-title text-center">Registro</h3>
2525
<div class="card-text">
2626
<!--
2727
<div class="alert alert-danger alert-dismissible fade show" role="alert">Incorrect username or password.</div> -->
28-
<form action="signin" method="post">
28+
<form action="/signin" method="post">
2929
<!-- to error: add class "has-danger" -->
3030
<div class="form-group">
3131
<label for="exampleInputEmail1">Nick</label>
@@ -37,7 +37,7 @@ <h3 class="card-title text-center">Registro</h3>
3737
</div>
3838
<div class="form-group">
3939
<label for="exampleInputEmail1">Apellidos</label>
40-
<input name="LastName" type="text" class="form-control form-control-sm" id="exampleInputEmail1" aria-describedby="emailHelp" required>
40+
<input name="lastName" type="text" class="form-control form-control-sm" id="exampleInputEmail1" aria-describedby="emailHelp" required>
4141
</div>
4242
<div class="form-group">
4343
<label for="exampleInputEmail1">Correo electrónico</label>

backend/gamelink/target/classes/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ spring.mustache.suffix=.html
1010

1111
spring.datasource.url=jdbc:postgresql://localhost/gamelink
1212
spring.datasource.username=postgres
13-
spring.datasource.password=Universum3
13+
spring.datasource.password=password
1414
spring.jpa.hibernate.ddl-auto=create-drop
1515

1616
logging.level.org.springframework.security=DEBUG

0 commit comments

Comments
 (0)