Skip to content

Commit

Permalink
feat(cart-customer): remove cart ID from storage when unauthenticated (
Browse files Browse the repository at this point in the history
  • Loading branch information
griest024 committed Jul 13, 2023
1 parent 5da2cfc commit e8fc2c4
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion libs/cart-customer/state/src/state.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { NgModule } from '@angular/core';
import {
NgModule,
inject,
} from '@angular/core';
import { EffectsModule } from '@ngrx/effects';

import { DAFF_AUTH_UNAUTHENTICATED_HOOKS } from '@daffodil/auth/state';
import { DaffCartStorageService } from '@daffodil/cart';

import { DaffCartCustomerAuthEffects } from './effects/auth.effects';

@NgModule({
Expand All @@ -9,5 +15,19 @@ import { DaffCartCustomerAuthEffects } from './effects/auth.effects';
DaffCartCustomerAuthEffects,
]),
],
providers: [
{
provide: DAFF_AUTH_UNAUTHENTICATED_HOOKS,
useFactory: () => {
const storage = inject(DaffCartStorageService);
return () => {
try {
storage.removeCartId();
} catch {}
};
},
multi: true,
},
],
})
export class DaffCartCustomerStateModule {}

0 comments on commit e8fc2c4

Please sign in to comment.