Skip to content

Commit

Permalink
Fix Sign In (Ahora setea datos de nuevo usuario mediante @RequestParam)
Browse files Browse the repository at this point in the history
  • Loading branch information
JhostinD committed Mar 14, 2022
1 parent 19cfb3a commit 649b6e4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,19 @@ public String signin(Model model){
}

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

if (user.getName().equals("") || user.getName() == null){
if (name.equals("") || name == null){
return "errorMessage";
}

ArrayList<String> lista = new ArrayList<>();
lista.add("USERO");
user.setName(name);
user.setEmail(email);
user.setNick(nick);
user.setLastName(lastName);
user.setRoles(lista);
user.setEncodedPassword(passwordEncoder.encode(password));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public void init() throws IOException, URISyntaxException {

/* inserting users into the database */

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

Usero usr3 = new Usero("admin", "adminPepe", "Uno", "[email protected]");
Usero usr3 = new Usero("admin", "adminName", "adminLastName", "[email protected]");
usr3.setEncodedPassword(passwordEncoder.encode("123"));
ArrayList<String> roles3 = new ArrayList<>();
roles3.add("USERO");
Expand Down
2 changes: 1 addition & 1 deletion backend/gamelink/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spring.mustache.suffix=.html

spring.datasource.url=jdbc:postgresql://localhost/gamelink
spring.datasource.username=postgres
spring.datasource.password=Universum3
spring.datasource.password=password
spring.jpa.hibernate.ddl-auto=create-drop

logging.level.org.springframework.security=DEBUG
Expand Down
4 changes: 2 additions & 2 deletions backend/gamelink/src/main/resources/templates/signin.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h3 class="card-title text-center">Registro</h3>
<div class="card-text">
<!--
<div class="alert alert-danger alert-dismissible fade show" role="alert">Incorrect username or password.</div> -->
<form action="signin" method="post">
<form action="/signin" method="post">
<!-- to error: add class "has-danger" -->
<div class="form-group">
<label for="exampleInputEmail1">Nick</label>
Expand All @@ -37,7 +37,7 @@ <h3 class="card-title text-center">Registro</h3>
</div>
<div class="form-group">
<label for="exampleInputEmail1">Apellidos</label>
<input name="LastName" type="text" class="form-control form-control-sm" id="exampleInputEmail1" aria-describedby="emailHelp" required>
<input name="lastName" type="text" class="form-control form-control-sm" id="exampleInputEmail1" aria-describedby="emailHelp" required>
</div>
<div class="form-group">
<label for="exampleInputEmail1">Correo electrónico</label>
Expand Down
2 changes: 1 addition & 1 deletion backend/gamelink/target/classes/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spring.mustache.suffix=.html

spring.datasource.url=jdbc:postgresql://localhost/gamelink
spring.datasource.username=postgres
spring.datasource.password=Universum3
spring.datasource.password=password
spring.jpa.hibernate.ddl-auto=create-drop

logging.level.org.springframework.security=DEBUG
Expand Down

0 comments on commit 649b6e4

Please sign in to comment.