Home > Software engineering >  Angular 13 with ngrx and OAuth2 issue creating an effect
Angular 13 with ngrx and OAuth2 issue creating an effect

Time:11-09

So I'm following this example, though it is an earlier version of Angular and ngrx.enter image description here

This means that authObj is not a boolean but a LoginResponse object. The effect should use the isAuthenticated property:

import * as fromAuthActions from '../Actions/auth.actions';
.......
checkauth$ = createEffect(() =>
this.actions$.pipe(
  ofType(fromAuthActions.checkAuth),
  switchMap(() =>
    this.authService
      .checkAuth()
      .pipe(
        map((response) => fromAuthActions.checkAuthComplete({ isLoggedIn: response.isAuthenticated ))
      )
   )
 )
);
  • Related