-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e7299d
commit 1c455ed
Showing
5 changed files
with
25 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,6 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Actions, createEffect, ofType } from '@ngrx/effects'; | ||
import { catchError, map, of, switchMap } from 'rxjs'; | ||
import { AuthApiService } from '../apis/auth-api.service'; | ||
import { AuthService } from '../services/auth.service'; | ||
|
||
import * as CoreActions from '../../../core/+state/core.actions'; | ||
import { UserWithTokenResponse } from '../dto/auth.dto'; | ||
import * as AuthActions from './auth.actions'; | ||
|
||
@Injectable() | ||
export class AuthEffects { | ||
constructor( | ||
private readonly actions$: Actions, | ||
private authApi: AuthApiService, | ||
private authService: AuthService | ||
) {} | ||
|
||
login$ = createEffect(() => | ||
this.actions$.pipe( | ||
ofType(AuthActions.login), | ||
switchMap(({ model }) => { | ||
return this.authApi.login(model).pipe( | ||
map((result: UserWithTokenResponse) => { | ||
this.authService.storeUserTokens(result); | ||
return CoreActions.loginSuccess({ result }); | ||
}), | ||
catchError((error) => of(AuthActions.LoginFailure({ error }))) | ||
); | ||
}) | ||
) | ||
); | ||
constructor() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters