@@ -7,7 +7,7 @@ import { catchError, map, switchMap } from 'rxjs/operators';
77import * as AuthActions from './auth.actions' ;
88import { AuthService } from '../services/auth.service' ;
99import { Credentials , ResetPasswordCredentials } from '../interfaces/credentials.interface' ;
10- import { AuthResponse , User } from '@app/modules/user/interfaces/user.interface' ;
10+ import { AuthResponse } from '@app/modules/user/interfaces/user.interface' ;
1111import { AccessTokenService } from '../services/access-token.service' ;
1212
1313@Injectable ( )
@@ -18,14 +18,14 @@ export class AuthEffects {
1818 switchMap ( ( { credentials } : { credentials : Credentials } ) =>
1919 this . authService . authenticate ( credentials ) . pipe (
2020 map ( ( authResponse : AuthResponse ) => {
21- this . accessTokenService . setAccessToken ( authResponse . data . access_token ) ;
21+ this . accessTokenService . setAccessToken ( authResponse . data . access_token , authResponse . data . expires_in ) ;
2222 this . router . navigateByUrl ( '/dashboard' ) ;
2323 return AuthActions . fetchAuthenticateSuccessAction ( { user : authResponse . data . user } ) ;
2424 } ) ,
2525 catchError ( ( error ) => {
2626 return of (
2727 AuthActions . authenticateFailureAction ( {
28- error : error . error ?. message ?? 'Unknown error occurred ' ,
28+ error : error . error ?. message ?? 'Une erreur est survenue ' ,
2929 } )
3030 )
3131 } )
@@ -42,7 +42,7 @@ export class AuthEffects {
4242 catchError ( ( error ) => {
4343 return of (
4444 AuthActions . forgotPasswordFailureAction ( {
45- error : error . error ?. message ?? 'Unknown error occurred ' ,
45+ error : error . error ?. message ?? 'Une erreur est survenue ' ,
4646 } )
4747 )
4848 } )
@@ -58,7 +58,7 @@ export class AuthEffects {
5858 catchError ( ( error ) => {
5959 return of (
6060 AuthActions . resetPasswordFailureAction ( {
61- error : error . error ?. message ?? 'Unknown error occurred ' ,
61+ error : error . error ?. message ?? 'Une erreur est survenue ' ,
6262 } )
6363 )
6464 }
@@ -70,7 +70,10 @@ export class AuthEffects {
7070 this . actions$ . pipe (
7171 ofType ( AuthActions . getCurrentUserAction ) ,
7272 switchMap ( ( ) => this . authService . getCurrentUser ( ) . pipe (
73- map ( ( user : User | null ) => AuthActions . fetchCurrentUserSuccessAction ( { user } ) ) ,
73+ map ( ( { data } : any ) => {
74+ console . log ( data ) ;
75+ return AuthActions . fetchCurrentUserSuccessAction ( { user : data . user } )
76+ } ) ,
7477 catchError ( ( ) => EMPTY )
7578 ) )
7679 )
0 commit comments