Skip to content

Commit e6a0f8c

Browse files
committed
no va el singup
1 parent 5326ceb commit e6a0f8c

File tree

8 files changed

+24
-12
lines changed

8 files changed

+24
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public ResponseEntity<Usero> getUser(@PathVariable long id) {
7474
@ResponseStatus(HttpStatus.CREATED)
7575
public ResponseEntity<Usero> createUser(Usero user, @RequestParam String password) {
7676

77-
user.setEncodedPassword(passwordEncoder.encode(password));
77+
user.setEncodedPassword(password);
7878
ArrayList<String> list = new ArrayList<>();
7979
list.add("USERO");
8080
user.setRoles(list);

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:5432/gamelink
1212
spring.datasource.username=postgres
13-
spring.datasource.password=password
13+
spring.datasource.password=Nekowa10
1414
spring.jpa.hibernate.ddl-auto=create-drop
1515

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

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:5432/gamelink
1212
spring.datasource.username=postgres
13-
spring.datasource.password=password
13+
spring.datasource.password=Nekowa10
1414
spring.jpa.hibernate.ddl-auto=create-drop
1515

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

frontend/src/app/components/login/login.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import { Component } from '@angular/core';
22
import { LoginService } from '../../services/login.service';
3+
import { Router } from '@angular/router';
34

45
@Component({
56
selector: 'login',
67
templateUrl: './login.component.html'
78
})
89
export class LoginComponent {
910

10-
constructor(public loginService: LoginService) { }
11+
constructor(private router: Router, public loginService: LoginService) { }
1112

1213
logIn(event: any, user: string, pass: string) {
1314

1415
event.preventDefault();
1516

1617
this.loginService.logIn(user, pass);
18+
this.router.navigate(['/userProfile']);
1719
}
1820

1921
logOut() {

frontend/src/app/components/login/signUp.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ <h3 class="card-title text-center">Registro</h3>
3939
<div class="form-group">
4040
<label for="exampleInputPassword1">Contraseña</label>
4141
<input #pass name="password" type="password" class="form-control form-control-sm"
42-
id="inputPassword1" onkeyup="check()" required>
42+
id="inputPassword1" required>
4343
</div>
4444
<div class="form-group">
4545
<label for="exampleInputPassword1">Confirmación contraseña</label>
4646
<input #pass type="password" class="form-control form-control-sm" id="inputPassword2"
47-
onkeyup="check()" required>
47+
required>
4848
<span id="passwordMessage"></span>
4949
</div>
5050
<a type="submit" (click)="createUser($event, nick.value, name.value, lastName.value, email.value,

frontend/src/app/components/login/signUp.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ export class SignUpComponent {
1515
event.preventDefault();
1616
var user: Usero = { nick, name, lastName, email, creditCard: "",image: false, roles: ['USERO']}
1717
this.useroService.createUser(user);
18+
19+
if(user.id){
20+
alert("Usuario creado exitoso");
21+
}else{
22+
alert("Error al crear el usuario");
23+
}
24+
25+
// this.router.navigate(['/login']);
1826
}
1927

2028
}

frontend/src/app/components/user/userProfile.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export class UserProfile {
4343
(user: any) => this.uploadImage(user as Usero),
4444
(error: string) => alert('Error al guardar los datos: ' + error)
4545
);
46+
this.router.navigate(['/userProfile']);
4647
}
4748
cancel() {
4849
window.history.back();

frontend/src/app/services/usero.service.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Videogame } from '../models/videogame.model';
55
import { News } from '../models/news.model';
66
import { Observable, throwError } from 'rxjs';
77
import { catchError } from 'rxjs/operators';
8+
import { Router } from '@angular/router';
89

910
const BASE_URL = '/api/users/';
1011

@@ -13,7 +14,7 @@ export class UseroService {
1314

1415
user!: Usero;
1516

16-
constructor(private http: HttpClient) {}
17+
constructor(private http: HttpClient, private router: Router) {}
1718

1819

1920
/*------------------GET METHODS------------------*/
@@ -55,12 +56,12 @@ export class UseroService {
5556

5657
/*------------------CREATE METHODS------------------*/
5758
createUser(user: Usero) {
58-
5959
if (!user.id) {
60-
return this.http.post(BASE_URL, user)
61-
.pipe(
62-
catchError((error: any) => this.handleError(error))
63-
);
60+
return this.http.post(BASE_URL, user, {withCredentials: true}).subscribe(
61+
(response) => this.router.navigate(['login']),
62+
(error) => alert('Usuario ya existe, inicie sesión')
63+
)
64+
6465
} else {
6566
return this.http.put(BASE_URL + user.id, user).pipe(
6667
catchError((error: any) => this.handleError(error))

0 commit comments

Comments
 (0)