Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 24x 24x 24x 24x 24x 24x 24x 24x 24x 6x 6x 6x 1x 6x 6x 2x 2x 1x | import { Injectable } from '@angular/core'; import { Actions, concatLatestFrom, createEffect, ofType } from '@ngrx/effects'; import { Store, select } from '@ngrx/store'; import { map, switchMap } from 'rxjs/operators'; import { AuthorizationService } from 'ish-core/services/authorization/authorization.service'; import { getLoggedInCustomer, getLoggedInUser, loadCompanyUserSuccess } from 'ish-core/store/customer/user'; import { mapErrorToAction } from 'ish-core/utils/operators'; import { loadRolesAndPermissions, loadRolesAndPermissionsFail, loadRolesAndPermissionsSuccess, } from './authorization.actions'; @Injectable() export class AuthorizationEffects { constructor(private actions$: Actions, private store: Store, private authorizationService: AuthorizationService) {} triggerLoading$ = createEffect(() => this.actions$.pipe( ofType(loadCompanyUserSuccess), map(() => loadRolesAndPermissions()) ) ); loadRolesAndPermissions$ = createEffect(() => this.actions$.pipe( ofType(loadRolesAndPermissions), concatLatestFrom(() => [this.store.pipe(select(getLoggedInUser)), this.store.pipe(select(getLoggedInCustomer))]), switchMap(([, user, customer]) => this.authorizationService.getRolesAndPermissions(customer, user).pipe( map(authorization => loadRolesAndPermissionsSuccess({ authorization })), mapErrorToAction(loadRolesAndPermissionsFail) ) ) ) ); } |