From a83a5d702b985e227b286a820fe0b1249d7e193c Mon Sep 17 00:00:00 2001 From: Zenith Wogwugwu Date: Sat, 4 Mar 2023 04:23:11 +0100 Subject: [PATCH] fix: minor fixes --- projects/ngx-jwt-auth/src/lib/auth-manager.service.ts | 6 +++--- projects/ngx-jwt-auth/src/lib/auth.service.ts | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/projects/ngx-jwt-auth/src/lib/auth-manager.service.ts b/projects/ngx-jwt-auth/src/lib/auth-manager.service.ts index caed621..ed3fb6a 100644 --- a/projects/ngx-jwt-auth/src/lib/auth-manager.service.ts +++ b/projects/ngx-jwt-auth/src/lib/auth-manager.service.ts @@ -7,10 +7,10 @@ import { JwtAuthService } from './jwt-auth.service'; import { AuthService } from './auth.service'; import { AuthDialogService } from './auth-dialog.service'; -import {User} from './user.interface'; +import { User } from './user.interface'; import { JwtInterface as JWT } from '@uzenith360/jwt-utils'; import AuthError from './auth-error'; -import {JWTAndUser} from './jwt-and-user.interface'; +import { JWTAndUser } from './jwt-and-user.interface'; @Injectable({ providedIn: 'root' @@ -37,7 +37,7 @@ export class AuthManagerService { map(({ jwt, message }) => { this.jwtAuthService.set(jwt); - return {message, user: this.jwtAuthService.decode(jwt)! } + return { message, user: this.jwtAuthService.decode(jwt)! } }) ); } diff --git a/projects/ngx-jwt-auth/src/lib/auth.service.ts b/projects/ngx-jwt-auth/src/lib/auth.service.ts index 1a2c515..d4532ac 100644 --- a/projects/ngx-jwt-auth/src/lib/auth.service.ts +++ b/projects/ngx-jwt-auth/src/lib/auth.service.ts @@ -4,7 +4,7 @@ import { HttpClient, HttpErrorResponse } from '@angular/common/http'; import { throwError, Observable } from 'rxjs'; import { map, catchError } from 'rxjs/operators'; -import {JwtInterface as JWT} from '@uzenith360/jwt-utils'; +import { JwtInterface as JWT } from '@uzenith360/jwt-utils'; import { HttpHelpers } from './http-helpers'; import { EnvironmentConfig } from './environment-config.interface'; import HttpError from './http-error'; @@ -25,7 +25,7 @@ export class AuthService { .pipe( HttpHelpers.retry(), catchError( - (err, caught: Observable) => { + (err, caught: Observable<{ jwt: JWT, message: string }>) => { switch (err.status) { case 401: return throwError(() => new HttpError('Login details are incorrect', err.status)); @@ -38,8 +38,8 @@ export class AuthService { }, ), map( - (jwt: JWT) => { - return { message: 'Successfully logged in', jwt }; + (data: { jwt: JWT, message: string }) => { + return { message: data.message || 'Successfully logged in', jwt: data.jwt }; }, ) );