From 41d3d618b3f209f5c6cf4ce66a7a25679179a3cd Mon Sep 17 00:00:00 2001 From: Jonatan Vicente Date: Mon, 29 Jan 2024 10:32:04 +0100 Subject: [PATCH] Comment Auth Service Calls --- src/app/interceptors/jwt-interceptor.ts | 22 ++++++++----------- .../login-modal/login-modal.component.ts | 4 ++-- .../register-modal.component.ts | 4 ++-- src/app/services/auth.service.ts | 14 ++++++------ 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/app/interceptors/jwt-interceptor.ts b/src/app/interceptors/jwt-interceptor.ts index 712569a8..3a8f2e88 100644 --- a/src/app/interceptors/jwt-interceptor.ts +++ b/src/app/interceptors/jwt-interceptor.ts @@ -20,27 +20,23 @@ export class JwtInterceptor implements HttpInterceptor { intercept(request: HttpRequest, next: HttpHandler): Observable> { - const currentUser = this.authService.currentUser; - const isLoggedIn = currentUser && currentUser.token; - const isApiUrl = request.url.startsWith(environment.BACKEND_ITA_SSO_BASE_URL); - - console.log('***************************'); - console.log(currentUser); - console.log(isLoggedIn); - console.log(isApiUrl); - - - + console.log('***************************INTERCEPTOR'); +/* const currentUser = this.authService.currentUser; + const isLoggedIn = currentUser && currentUser.token; + const isApiUrl = request.url.startsWith(environment.BACKEND_ITA_SSO_BASE_URL);*/ +/* console.log(currentUser); + console.log(isLoggedIn); + console.log(isApiUrl);*/ - if (isLoggedIn && isApiUrl) { + /* if (isLoggedIn && isApiUrl) { request = request.clone({ setHeaders: { Authorization: `Bearer ${currentUser.token}` } }); - } + }*/ return next.handle(request); } diff --git a/src/app/modules/modals/login-modal/login-modal.component.ts b/src/app/modules/modals/login-modal/login-modal.component.ts index cd50862e..94f716ee 100644 --- a/src/app/modules/modals/login-modal/login-modal.component.ts +++ b/src/app/modules/modals/login-modal/login-modal.component.ts @@ -32,7 +32,7 @@ export class LoginModalComponent { console.log('*************', this.loginForm) - this.authService.login(dni, password).subscribe({ +/* this.authService.login(dni, password).subscribe({ next: (userData) => { console.log(userData, "login") // actions like redirecting user to another page @@ -55,7 +55,7 @@ export class LoginModalComponent { // this.router.navigateByUrl('/') this.closeModal(); } - }); + });*/ } else { diff --git a/src/app/modules/modals/register-modal/register-modal.component.ts b/src/app/modules/modals/register-modal/register-modal.component.ts index cfe337c5..bc166cc4 100644 --- a/src/app/modules/modals/register-modal/register-modal.component.ts +++ b/src/app/modules/modals/register-modal/register-modal.component.ts @@ -42,14 +42,14 @@ export class RegisterModalComponent { user.itineraryId = environment.ITINERARY_ID; console.log('from register-modal********', user) - this.authService.register(user).subscribe({ +/* this.authService.register(user).subscribe({ next: (userData) => {console.log('userData ' , userData)}, error: (errorData) => { console.error("Error during registration", errorData); this.registerError = errorData.error || 'Error en el registro'; // Accede a la propiedad error de HttpErrorResponse }, - }); + });*/ } this.closeModal(); } diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index a16e2b75..7aa87e19 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -17,17 +17,17 @@ import { Router } from "@angular/router"; @Injectable() export class AuthService { - private userSubject: BehaviorSubject; - public user: Observable; +/* private userSubject: BehaviorSubject; + public user: Observable;*/ constructor(private http: HttpClient, private router: Router) { - this.userSubject = new BehaviorSubject(JSON.parse(localStorage.getItem("user")!)); + //this.userSubject = new BehaviorSubject(JSON.parse(localStorage.getItem("user")!)); - console.log("*******"+JSON.stringify(this.userSubject)); - this.user = this.userSubject.asObservable(); + //console.log("*******"+JSON.stringify(this.userSubject)); + //this.user = this.userSubject.asObservable(); } - public get currentUser(): User { + /*public get currentUser(): User { return this.userSubject.value; } @@ -125,5 +125,5 @@ export class AuthService { public getExpiration() { const expiration = localStorage.getItem("expires_at"); return expiration != null ? JSON.parse(expiration) : null; - } + }*/ }