Skip to content

Commit

Permalink
fix: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
uzenith360 committed Mar 4, 2023
1 parent 02d346e commit a83a5d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions projects/ngx-jwt-auth/src/lib/auth-manager.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -37,7 +37,7 @@ export class AuthManagerService {
map(({ jwt, message }) => {
this.jwtAuthService.set(jwt);

return {message, user: this.jwtAuthService.decode<User>(jwt)! }
return { message, user: this.jwtAuthService.decode<User>(jwt)! }
})
);
}
Expand Down
8 changes: 4 additions & 4 deletions projects/ngx-jwt-auth/src/lib/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -25,7 +25,7 @@ export class AuthService {
.pipe(
HttpHelpers.retry(),
catchError(
(err, caught: Observable<JWT>) => {
(err, caught: Observable<{ jwt: JWT, message: string }>) => {
switch (err.status) {
case 401:
return throwError(() => new HttpError('Login details are incorrect', err.status));
Expand All @@ -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 };
},
)
);
Expand Down

0 comments on commit a83a5d7

Please sign in to comment.