diff --git a/frontend/src/app/services/auth.service.ts b/frontend/src/app/services/auth.service.ts index ac10c9b..f88cc1c 100644 --- a/frontend/src/app/services/auth.service.ts +++ b/frontend/src/app/services/auth.service.ts @@ -1,6 +1,6 @@ import {Injectable} from '@angular/core'; import {LoginService} from '@api'; -import {BehaviorSubject, from, Observable, of, switchMap, throwError} from 'rxjs'; +import {BehaviorSubject, Observable, throwError} from 'rxjs'; import {catchError, tap} from 'rxjs/operators'; import {MatSnackBar} from '@angular/material/snack-bar'; import {JwtHelperService} from '@auth0/angular-jwt'; @@ -25,34 +25,14 @@ export class AuthService { this.checkAuthStatus(); } - private isBlob(value: any): boolean { - return value instanceof Blob; - } - - private getAsBlob(value: any): Blob { - return value as Blob; - } - /** * Attempt to login with the provided code */ public login(code: string): Observable { return this.loginService.login(code).pipe( - switchMap(response => { - if (this.isBlob(response)) { - return from(this.getAsBlob(response).text()).pipe( - tap(jwtText => { - console.log('JWT from Blob:', jwtText); - this.saveJwt(jwtText); - this.isAuthenticatedSubject.next(true); - }) - ); - } else { - console.log('JWT as string:', response); - this.saveJwt(atob(response)); - this.isAuthenticatedSubject.next(true); - return of(response); - } + tap(jwt => { + this.saveJwt(jwt); + this.isAuthenticatedSubject.next(true); }), catchError(error => { this.snackBar.open('Login failed', '', {duration: 2000});