@daffodil/auth 0.59.2 → 0.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/driver/in-memory/package.json +1 -1
- package/driver/magento/package.json +1 -1
- package/driver/package.json +1 -1
- package/driver/testing/package.json +1 -1
- package/esm2020/state/auth-state.module.mjs +5 -4
- package/esm2020/state/effects/login.effects.mjs +11 -15
- package/esm2020/state/facades/auth/facade.mjs +5 -5
- package/esm2020/state/facades/login/facade.mjs +5 -5
- package/esm2020/state/facades/register/facade.mjs +5 -5
- package/esm2020/state/facades/reset-password/facade.mjs +5 -5
- package/esm2020/state/reducers/auth/auth-initial-state.mjs +3 -3
- package/esm2020/state/reducers/auth/auth-reducer-state.interface.mjs +1 -1
- package/esm2020/state/reducers/auth/auth.reducer.mjs +6 -16
- package/esm2020/state/reducers/login/login-initial-state.mjs +3 -5
- package/esm2020/state/reducers/login/login-reducer-state.interface.mjs +1 -1
- package/esm2020/state/reducers/login/login.reducer.mjs +5 -15
- package/esm2020/state/reducers/public_api.mjs +2 -1
- package/esm2020/state/reducers/register/register-initial-state.mjs +3 -5
- package/esm2020/state/reducers/register/register-reducer-state.interface.mjs +1 -1
- package/esm2020/state/reducers/register/register.reducer.mjs +5 -15
- package/esm2020/state/reducers/reset-password/initial-state.mjs +3 -3
- package/esm2020/state/reducers/reset-password/reducer.mjs +5 -15
- package/esm2020/state/reducers/reset-password/state.interface.mjs +1 -1
- package/esm2020/state/reducers/token/extra.token.mjs +27 -0
- package/esm2020/state/reducers/token/public_api.mjs +2 -0
- package/esm2020/state/reducers/token/reducers.token.mjs +18 -0
- package/esm2020/state/selectors/auth/auth.selector.mjs +4 -6
- package/esm2020/state/selectors/auth-all.selector.mjs +9 -9
- package/esm2020/state/selectors/login/login.selector.mjs +4 -6
- package/esm2020/state/selectors/public_api.mjs +5 -1
- package/esm2020/state/selectors/register/register.selector.mjs +4 -6
- package/esm2020/state/selectors/reset-password/selector.mjs +4 -6
- package/fesm2015/daffodil-auth-state.mjs +94 -96
- package/fesm2015/daffodil-auth-state.mjs.map +1 -1
- package/fesm2020/daffodil-auth-state.mjs +95 -123
- package/fesm2020/daffodil-auth-state.mjs.map +1 -1
- package/package.json +1 -1
- package/routing/package.json +1 -1
- package/state/effects/login.effects.d.ts +3 -6
- package/state/facades/auth/facade.d.ts +2 -2
- package/state/facades/login/facade.d.ts +2 -2
- package/state/facades/register/facade.d.ts +2 -2
- package/state/facades/reset-password/facade.d.ts +2 -2
- package/state/package.json +1 -1
- package/state/reducers/auth/auth-reducer-state.interface.d.ts +2 -4
- package/state/reducers/login/login-reducer-state.interface.d.ts +2 -5
- package/state/reducers/login/login.reducer.d.ts +1 -1
- package/state/reducers/public_api.d.ts +1 -0
- package/state/reducers/register/register-reducer-state.interface.d.ts +2 -5
- package/state/reducers/register/register.reducer.d.ts +1 -1
- package/state/reducers/reset-password/state.interface.d.ts +2 -4
- package/state/reducers/token/extra.token.d.ts +22 -0
- package/state/reducers/token/public_api.d.ts +1 -0
- package/state/reducers/token/reducers.token.d.ts +10 -0
- package/state/selectors/auth/auth.selector.d.ts +6 -8
- package/state/selectors/login/login.selector.d.ts +5 -7
- package/state/selectors/public_api.d.ts +4 -0
- package/state/selectors/register/register.selector.d.ts +5 -8
- package/state/selectors/reset-password/selector.d.ts +6 -8
- package/state/testing/package.json +1 -1
- package/testing/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createFeatureSelector, createSelector, select, StoreModule } from '@ngrx/store';
|
|
1
|
+
import { daffOperationInitialState, daffOperationFailed, daffCompleteOperation, daffStartResolution, daffStartMutation, daffOperationStateSelectorFactory, daffComposeReducers } from '@daffodil/core/state';
|
|
3
2
|
import * as i0 from '@angular/core';
|
|
4
|
-
import {
|
|
3
|
+
import { InjectionToken, Injectable, Inject, inject, NgModule } from '@angular/core';
|
|
4
|
+
import * as i1 from '@ngrx/store';
|
|
5
|
+
import { createFeatureSelector, createSelector, select, combineReducers, StoreModule } from '@ngrx/store';
|
|
5
6
|
import * as i1$1 from '@ngrx/effects';
|
|
6
7
|
import { createEffect, ofType, EffectsModule } from '@ngrx/effects';
|
|
7
8
|
import { of, EMPTY, iif, defer } from 'rxjs';
|
|
@@ -272,40 +273,28 @@ class DaffResetPasswordLanding {
|
|
|
272
273
|
}
|
|
273
274
|
|
|
274
275
|
const daffAuthInitialState = {
|
|
275
|
-
|
|
276
|
-
errors: [],
|
|
276
|
+
...daffOperationInitialState,
|
|
277
277
|
loggedIn: false,
|
|
278
278
|
};
|
|
279
279
|
|
|
280
280
|
function daffAuthReducer(state = daffAuthInitialState, action) {
|
|
281
281
|
switch (action.type) {
|
|
282
282
|
case DaffAuthActionTypes.AuthCheckAction:
|
|
283
|
-
return
|
|
284
|
-
...state,
|
|
285
|
-
loading: true,
|
|
286
|
-
};
|
|
283
|
+
return daffStartResolution(state);
|
|
287
284
|
case DaffAuthActionTypes.AuthCheckSuccessAction:
|
|
288
285
|
return {
|
|
289
|
-
...state,
|
|
286
|
+
...daffCompleteOperation(state),
|
|
290
287
|
loggedIn: true,
|
|
291
|
-
loading: false,
|
|
292
|
-
errors: [],
|
|
293
288
|
};
|
|
294
289
|
case DaffAuthActionTypes.AuthCheckFailureAction:
|
|
295
290
|
case DaffAuthActionTypes.AuthGuardLogoutAction:
|
|
296
291
|
return {
|
|
297
|
-
...state,
|
|
292
|
+
...daffOperationFailed([action.errorMessage], state),
|
|
298
293
|
loggedIn: false,
|
|
299
|
-
loading: false,
|
|
300
|
-
errors: [action.errorMessage],
|
|
301
294
|
};
|
|
302
295
|
case DaffAuthActionTypes.AuthServerSideAction:
|
|
303
296
|
case DaffAuthActionTypes.AuthStorageFailureAction:
|
|
304
|
-
return
|
|
305
|
-
...state,
|
|
306
|
-
loading: false,
|
|
307
|
-
errors: [action.errorMessage],
|
|
308
|
-
};
|
|
297
|
+
return daffOperationFailed([action.errorMessage], state);
|
|
309
298
|
case DaffAuthLoginActionTypes.LoginSuccessAction:
|
|
310
299
|
return {
|
|
311
300
|
...state,
|
|
@@ -327,70 +316,41 @@ function daffAuthReducer(state = daffAuthInitialState, action) {
|
|
|
327
316
|
}
|
|
328
317
|
}
|
|
329
318
|
|
|
330
|
-
const daffAuthLoginInitialState =
|
|
331
|
-
loading: false,
|
|
332
|
-
errors: [],
|
|
333
|
-
};
|
|
319
|
+
const daffAuthLoginInitialState = daffOperationInitialState;
|
|
334
320
|
|
|
335
321
|
function daffAuthLoginReducer(state = daffAuthLoginInitialState, action) {
|
|
336
322
|
switch (action.type) {
|
|
337
323
|
case DaffAuthLoginActionTypes.LoginAction:
|
|
338
324
|
case DaffAuthLoginActionTypes.LogoutAction:
|
|
339
|
-
return
|
|
340
|
-
...state,
|
|
341
|
-
loading: true,
|
|
342
|
-
};
|
|
325
|
+
return daffStartMutation(state);
|
|
343
326
|
case DaffAuthLoginActionTypes.LoginSuccessAction:
|
|
344
327
|
case DaffAuthLoginActionTypes.LogoutSuccessAction:
|
|
345
|
-
return
|
|
346
|
-
...state,
|
|
347
|
-
loading: false,
|
|
348
|
-
errors: [],
|
|
349
|
-
};
|
|
328
|
+
return daffCompleteOperation(state);
|
|
350
329
|
case DaffAuthLoginActionTypes.LoginFailureAction:
|
|
351
330
|
case DaffAuthLoginActionTypes.LogoutFailureAction:
|
|
352
|
-
return
|
|
353
|
-
...state,
|
|
354
|
-
loading: false,
|
|
355
|
-
errors: [action.errorMessage],
|
|
356
|
-
};
|
|
331
|
+
return daffOperationFailed([action.errorMessage], state);
|
|
357
332
|
default:
|
|
358
333
|
return state;
|
|
359
334
|
}
|
|
360
335
|
}
|
|
361
336
|
|
|
362
|
-
const daffAuthRegisterInitialState =
|
|
363
|
-
loading: false,
|
|
364
|
-
errors: [],
|
|
365
|
-
};
|
|
337
|
+
const daffAuthRegisterInitialState = daffOperationInitialState;
|
|
366
338
|
|
|
367
339
|
function daffAuthRegisterReducer(state = daffAuthRegisterInitialState, action) {
|
|
368
340
|
switch (action.type) {
|
|
369
341
|
case DaffAuthRegisterActionTypes.RegisterAction:
|
|
370
|
-
return
|
|
371
|
-
...state,
|
|
372
|
-
loading: true,
|
|
373
|
-
};
|
|
342
|
+
return daffStartMutation(state);
|
|
374
343
|
case DaffAuthRegisterActionTypes.RegisterSuccessAction:
|
|
375
|
-
return
|
|
376
|
-
...state,
|
|
377
|
-
loading: false,
|
|
378
|
-
errors: [],
|
|
379
|
-
};
|
|
344
|
+
return daffCompleteOperation(state);
|
|
380
345
|
case DaffAuthRegisterActionTypes.RegisterFailureAction:
|
|
381
|
-
return
|
|
382
|
-
...state,
|
|
383
|
-
loading: false,
|
|
384
|
-
errors: [action.errorMessage],
|
|
385
|
-
};
|
|
346
|
+
return daffOperationFailed([action.errorMessage], state);
|
|
386
347
|
default:
|
|
387
348
|
return state;
|
|
388
349
|
}
|
|
389
350
|
}
|
|
390
351
|
|
|
391
352
|
const daffAuthResetPasswordInitialState = {
|
|
392
|
-
|
|
393
|
-
errors: [],
|
|
353
|
+
...daffOperationInitialState,
|
|
394
354
|
token: null,
|
|
395
355
|
};
|
|
396
356
|
|
|
@@ -398,24 +358,13 @@ function daffAuthResetPasswordReducer(state = daffAuthResetPasswordInitialState,
|
|
|
398
358
|
switch (action.type) {
|
|
399
359
|
case DaffAuthResetPasswordActionTypes.ResetPasswordAction:
|
|
400
360
|
case DaffAuthResetPasswordActionTypes.SendResetEmailAction:
|
|
401
|
-
return
|
|
402
|
-
...state,
|
|
403
|
-
loading: true,
|
|
404
|
-
};
|
|
361
|
+
return daffStartMutation(state);
|
|
405
362
|
case DaffAuthResetPasswordActionTypes.ResetPasswordSuccessAction:
|
|
406
363
|
case DaffAuthResetPasswordActionTypes.SendResetEmailSuccessAction:
|
|
407
|
-
return
|
|
408
|
-
...state,
|
|
409
|
-
loading: false,
|
|
410
|
-
errors: [],
|
|
411
|
-
};
|
|
364
|
+
return daffCompleteOperation(state);
|
|
412
365
|
case DaffAuthResetPasswordActionTypes.ResetPasswordFailureAction:
|
|
413
366
|
case DaffAuthResetPasswordActionTypes.SendResetEmailFailureAction:
|
|
414
|
-
return
|
|
415
|
-
...state,
|
|
416
|
-
loading: false,
|
|
417
|
-
errors: [action.errorMessage],
|
|
418
|
-
};
|
|
367
|
+
return daffOperationFailed([action.errorMessage], state);
|
|
419
368
|
case DaffAuthResetPasswordActionTypes.ResetPasswordLandingAction:
|
|
420
369
|
return {
|
|
421
370
|
...state,
|
|
@@ -426,6 +375,32 @@ function daffAuthResetPasswordReducer(state = daffAuthResetPasswordInitialState,
|
|
|
426
375
|
}
|
|
427
376
|
}
|
|
428
377
|
|
|
378
|
+
/**
|
|
379
|
+
* A token to hold the injectable extra reducers.
|
|
380
|
+
*
|
|
381
|
+
* Prefer using {@link daffAuthProvideExtraReducers}.
|
|
382
|
+
*/
|
|
383
|
+
const DAFF_AUTH_EXTRA_REDUCERS = new InjectionToken('DAFF_AUTH_EXTRA_REDUCERS', { factory: () => [] });
|
|
384
|
+
/**
|
|
385
|
+
* Provides additional reducers that run after the standard Daffodil auth reducers.
|
|
386
|
+
*
|
|
387
|
+
* ```ts
|
|
388
|
+
* providers: [
|
|
389
|
+
* ...daffAuthProvideExtraReducers(
|
|
390
|
+
* myReducer1,
|
|
391
|
+
* myReducer2
|
|
392
|
+
* )
|
|
393
|
+
* ]
|
|
394
|
+
* ```
|
|
395
|
+
*/
|
|
396
|
+
function daffAuthProvideExtraReducers(...reducers) {
|
|
397
|
+
return reducers.map(reducer => ({
|
|
398
|
+
provide: DAFF_AUTH_EXTRA_REDUCERS,
|
|
399
|
+
useValue: reducer,
|
|
400
|
+
multi: true,
|
|
401
|
+
}));
|
|
402
|
+
}
|
|
403
|
+
|
|
429
404
|
const DAFF_AUTH_STORE_FEATURE_KEY = 'daffAuth';
|
|
430
405
|
|
|
431
406
|
const daffAuthReducers = {
|
|
@@ -445,64 +420,52 @@ const getDaffAuthFeatureStateSelector = (() => {
|
|
|
445
420
|
|
|
446
421
|
const createAuthSelectors = () => {
|
|
447
422
|
const selectAuthState = createSelector(getDaffAuthFeatureStateSelector(), state => state.auth);
|
|
448
|
-
const selectAuthLoading = createSelector(selectAuthState, state => state.loading);
|
|
449
|
-
const selectAuthErrors = createSelector(selectAuthState, state => state.errors);
|
|
450
423
|
const selectAuthLoggedIn = createSelector(selectAuthState, state => state.loggedIn);
|
|
451
424
|
return {
|
|
425
|
+
...daffOperationStateSelectorFactory(selectAuthState),
|
|
452
426
|
selectAuthState,
|
|
453
|
-
selectAuthLoading,
|
|
454
|
-
selectAuthErrors,
|
|
455
427
|
selectAuthLoggedIn,
|
|
456
428
|
};
|
|
457
429
|
};
|
|
458
|
-
const
|
|
430
|
+
const daffAuthSelectorFactory = (() => {
|
|
459
431
|
let cache;
|
|
460
432
|
return () => cache = cache || createAuthSelectors();
|
|
461
433
|
})();
|
|
462
434
|
|
|
463
435
|
const createLoginSelectors = () => {
|
|
464
436
|
const selectAuthLoginState = createSelector(getDaffAuthFeatureStateSelector(), state => state.login);
|
|
465
|
-
const selectAuthLoginLoading = createSelector(selectAuthLoginState, state => state.loading);
|
|
466
|
-
const selectAuthLoginErrors = createSelector(selectAuthLoginState, state => state.errors);
|
|
467
437
|
return {
|
|
438
|
+
...daffOperationStateSelectorFactory(selectAuthLoginState),
|
|
468
439
|
selectAuthLoginState,
|
|
469
|
-
selectAuthLoginLoading,
|
|
470
|
-
selectAuthLoginErrors,
|
|
471
440
|
};
|
|
472
441
|
};
|
|
473
|
-
const
|
|
442
|
+
const daffAuthLoginSelectorFactory = (() => {
|
|
474
443
|
let cache;
|
|
475
444
|
return () => cache = cache || createLoginSelectors();
|
|
476
445
|
})();
|
|
477
446
|
|
|
478
447
|
const createRegisterSelectors = () => {
|
|
479
448
|
const selectAuthRegisterState = createSelector(getDaffAuthFeatureStateSelector(), state => state.register);
|
|
480
|
-
const selectAuthRegisterLoading = createSelector(selectAuthRegisterState, state => state.loading);
|
|
481
|
-
const selectAuthRegisterErrors = createSelector(selectAuthRegisterState, state => state.errors);
|
|
482
449
|
return {
|
|
450
|
+
...daffOperationStateSelectorFactory(selectAuthRegisterState),
|
|
483
451
|
selectAuthRegisterState,
|
|
484
|
-
selectAuthRegisterLoading,
|
|
485
|
-
selectAuthRegisterErrors,
|
|
486
452
|
};
|
|
487
453
|
};
|
|
488
|
-
const
|
|
454
|
+
const daffAuthRegisterSelectorFactory = (() => {
|
|
489
455
|
let cache;
|
|
490
456
|
return () => cache = cache || createRegisterSelectors();
|
|
491
457
|
})();
|
|
492
458
|
|
|
493
459
|
const createResetPasswordSelectors = () => {
|
|
494
460
|
const selectAuthResetPasswordState = createSelector(getDaffAuthFeatureStateSelector(), state => state.resetPassword);
|
|
495
|
-
const selectAuthResetPasswordLoading = createSelector(selectAuthResetPasswordState, state => state.loading);
|
|
496
|
-
const selectAuthResetPasswordErrors = createSelector(selectAuthResetPasswordState, state => state.errors);
|
|
497
461
|
const selectAuthResetPasswordToken = createSelector(selectAuthResetPasswordState, state => state.token);
|
|
498
462
|
return {
|
|
463
|
+
...daffOperationStateSelectorFactory(selectAuthResetPasswordState),
|
|
499
464
|
selectAuthResetPasswordState,
|
|
500
|
-
selectAuthResetPasswordLoading,
|
|
501
|
-
selectAuthResetPasswordErrors,
|
|
502
465
|
selectAuthResetPasswordToken,
|
|
503
466
|
};
|
|
504
467
|
};
|
|
505
|
-
const
|
|
468
|
+
const daffAuthResetPasswordSelectorFactory = (() => {
|
|
506
469
|
let cache;
|
|
507
470
|
return () => cache = cache || createResetPasswordSelectors();
|
|
508
471
|
})();
|
|
@@ -510,10 +473,10 @@ const getDaffAuthResetPasswordSelectors = (() => {
|
|
|
510
473
|
const getDaffAuthSelectors = (() => {
|
|
511
474
|
let cache;
|
|
512
475
|
return () => cache = cache || {
|
|
513
|
-
...
|
|
514
|
-
...
|
|
515
|
-
...
|
|
516
|
-
...
|
|
476
|
+
...daffAuthSelectorFactory(),
|
|
477
|
+
...daffAuthLoginSelectorFactory(),
|
|
478
|
+
...daffAuthRegisterSelectorFactory(),
|
|
479
|
+
...daffAuthResetPasswordSelectorFactory(),
|
|
517
480
|
selectAuthFeatureState: getDaffAuthFeatureStateSelector(),
|
|
518
481
|
};
|
|
519
482
|
})();
|
|
@@ -524,9 +487,9 @@ const getDaffAuthSelectors = (() => {
|
|
|
524
487
|
class DaffAuthFacade {
|
|
525
488
|
constructor(store) {
|
|
526
489
|
this.store = store;
|
|
527
|
-
const {
|
|
528
|
-
this.loading$ = this.store.pipe(select(
|
|
529
|
-
this.errors$ = this.store.pipe(select(
|
|
490
|
+
const { selectLoading, selectErrors, selectAuthLoggedIn, } = daffAuthSelectorFactory();
|
|
491
|
+
this.loading$ = this.store.pipe(select(selectLoading));
|
|
492
|
+
this.errors$ = this.store.pipe(select(selectErrors));
|
|
530
493
|
this.loggedIn$ = this.store.pipe(select(selectAuthLoggedIn));
|
|
531
494
|
}
|
|
532
495
|
dispatch(action) {
|
|
@@ -548,9 +511,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
548
511
|
class DaffAuthLoginFacade {
|
|
549
512
|
constructor(store) {
|
|
550
513
|
this.store = store;
|
|
551
|
-
const {
|
|
552
|
-
this.loading$ = this.store.pipe(select(
|
|
553
|
-
this.errors$ = this.store.pipe(select(
|
|
514
|
+
const { selectLoading, selectErrors, } = daffAuthLoginSelectorFactory();
|
|
515
|
+
this.loading$ = this.store.pipe(select(selectLoading));
|
|
516
|
+
this.errors$ = this.store.pipe(select(selectErrors));
|
|
554
517
|
}
|
|
555
518
|
dispatch(action) {
|
|
556
519
|
this.store.dispatch(action);
|
|
@@ -571,9 +534,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
571
534
|
class DaffAuthRegisterFacade {
|
|
572
535
|
constructor(store) {
|
|
573
536
|
this.store = store;
|
|
574
|
-
const {
|
|
575
|
-
this.loading$ = this.store.pipe(select(
|
|
576
|
-
this.errors$ = this.store.pipe(select(
|
|
537
|
+
const { selectLoading, selectErrors, } = daffAuthRegisterSelectorFactory();
|
|
538
|
+
this.loading$ = this.store.pipe(select(selectLoading));
|
|
539
|
+
this.errors$ = this.store.pipe(select(selectErrors));
|
|
577
540
|
}
|
|
578
541
|
dispatch(action) {
|
|
579
542
|
this.store.dispatch(action);
|
|
@@ -594,10 +557,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
594
557
|
class DaffAuthResetPasswordFacade {
|
|
595
558
|
constructor(store) {
|
|
596
559
|
this.store = store;
|
|
597
|
-
const {
|
|
560
|
+
const { selectLoading, selectErrors, selectAuthResetPasswordToken, } = daffAuthResetPasswordSelectorFactory();
|
|
598
561
|
this.token$ = this.store.pipe(select(selectAuthResetPasswordToken));
|
|
599
|
-
this.loading$ = this.store.pipe(select(
|
|
600
|
-
this.errors$ = this.store.pipe(select(
|
|
562
|
+
this.loading$ = this.store.pipe(select(selectLoading));
|
|
563
|
+
this.errors$ = this.store.pipe(select(selectErrors));
|
|
601
564
|
}
|
|
602
565
|
dispatch(action) {
|
|
603
566
|
this.store.dispatch(action);
|
|
@@ -680,30 +643,26 @@ class DaffAuthLoginEffects {
|
|
|
680
643
|
this.loginDriver = loginDriver;
|
|
681
644
|
this.errorMatcher = errorMatcher;
|
|
682
645
|
this.storage = storage;
|
|
683
|
-
this.login$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthLoginActionTypes.LoginAction), switchMap((action) => this.loginDriver.login(action.loginInfo)
|
|
684
|
-
|
|
685
|
-
this.removeAuthToken$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthLoginActionTypes.LogoutSuccessAction), tap(() => {
|
|
686
|
-
this.storage.removeAuthToken();
|
|
687
|
-
}), switchMap(() => EMPTY), catchError((error) => {
|
|
646
|
+
this.login$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthLoginActionTypes.LoginAction), switchMap((action) => this.loginDriver.login(action.loginInfo)
|
|
647
|
+
.pipe(map((resp) => new DaffAuthLoginSuccess(resp)), tap((success) => this.storage.setAuthToken(success.auth.token)), catchError((error) => {
|
|
688
648
|
switch (true) {
|
|
689
649
|
case error instanceof DaffServerSideStorageError:
|
|
690
650
|
return of(new DaffAuthServerSide(this.errorMatcher(error)));
|
|
691
651
|
case error instanceof DaffStorageServiceError:
|
|
692
652
|
default:
|
|
693
|
-
return of(new
|
|
653
|
+
return of(new DaffAuthLoginFailure(this.errorMatcher(error)));
|
|
694
654
|
}
|
|
695
|
-
}))
|
|
696
|
-
this.
|
|
697
|
-
this.storage.setAuthToken(action.auth.token);
|
|
698
|
-
}), switchMap(() => EMPTY), catchError((error) => {
|
|
655
|
+
})))));
|
|
656
|
+
this.logout$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthLoginActionTypes.LogoutAction), switchMap((action) => this.loginDriver.logout().pipe(map(() => new DaffAuthLogoutSuccess()), tap(() => this.storage.removeAuthToken()), catchError((error) => {
|
|
699
657
|
switch (true) {
|
|
700
658
|
case error instanceof DaffServerSideStorageError:
|
|
701
659
|
return of(new DaffAuthServerSide(this.errorMatcher(error)));
|
|
702
660
|
case error instanceof DaffStorageServiceError:
|
|
703
|
-
default:
|
|
704
661
|
return of(new DaffAuthStorageFailure(this.errorMatcher(error)));
|
|
662
|
+
default:
|
|
663
|
+
return of(new DaffAuthLogoutFailure(this.errorMatcher(error)));
|
|
705
664
|
}
|
|
706
|
-
}))
|
|
665
|
+
})))));
|
|
707
666
|
}
|
|
708
667
|
}
|
|
709
668
|
/** @nocollapse */ DaffAuthLoginEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffAuthLoginEffects, deps: [{ token: i1$1.Actions }, { token: DaffLoginDriver }, { token: DAFF_AUTH_ERROR_MATCHER }, { token: i2$1.DaffAuthStorageService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -779,6 +738,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
779
738
|
args: [DAFF_AUTH_ERROR_MATCHER]
|
|
780
739
|
}] }, { type: i2$1.DaffAuthStorageService }]; } });
|
|
781
740
|
|
|
741
|
+
/**
|
|
742
|
+
* An internal token to hold the Daffodil auth reducers.
|
|
743
|
+
* Includes the extra and standard reducers.
|
|
744
|
+
*
|
|
745
|
+
* @docs-private
|
|
746
|
+
*/
|
|
747
|
+
const DAFF_AUTH_REDUCERS = new InjectionToken('DAFF_AUTH_REDUCERS', {
|
|
748
|
+
factory: () => daffComposeReducers([
|
|
749
|
+
combineReducers(daffAuthReducers),
|
|
750
|
+
...inject(DAFF_AUTH_EXTRA_REDUCERS),
|
|
751
|
+
]),
|
|
752
|
+
});
|
|
753
|
+
|
|
782
754
|
class DaffAuthStateModule {
|
|
783
755
|
static withConfig(config = {}) {
|
|
784
756
|
return {
|
|
@@ -795,7 +767,7 @@ class DaffAuthStateModule {
|
|
|
795
767
|
/** @nocollapse */ DaffAuthStateModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffAuthStateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
796
768
|
/** @nocollapse */ DaffAuthStateModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffAuthStateModule, imports: [i1.StoreFeatureModule, i1$1.EffectsFeatureModule] });
|
|
797
769
|
/** @nocollapse */ DaffAuthStateModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffAuthStateModule, imports: [[
|
|
798
|
-
StoreModule.forFeature(DAFF_AUTH_STORE_FEATURE_KEY,
|
|
770
|
+
StoreModule.forFeature(DAFF_AUTH_STORE_FEATURE_KEY, DAFF_AUTH_REDUCERS),
|
|
799
771
|
EffectsModule.forFeature([
|
|
800
772
|
DaffAuthEffects,
|
|
801
773
|
DaffAuthLoginEffects,
|
|
@@ -807,7 +779,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
807
779
|
type: NgModule,
|
|
808
780
|
args: [{
|
|
809
781
|
imports: [
|
|
810
|
-
StoreModule.forFeature(DAFF_AUTH_STORE_FEATURE_KEY,
|
|
782
|
+
StoreModule.forFeature(DAFF_AUTH_STORE_FEATURE_KEY, DAFF_AUTH_REDUCERS),
|
|
811
783
|
EffectsModule.forFeature([
|
|
812
784
|
DaffAuthEffects,
|
|
813
785
|
DaffAuthLoginEffects,
|
|
@@ -822,5 +794,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
822
794
|
* Generated bundle index. Do not edit.
|
|
823
795
|
*/
|
|
824
796
|
|
|
825
|
-
export { DAFF_AUTH_STATE_CONFIG, DAFF_AUTH_STORE_FEATURE_KEY, DaffAuthActionTypes, DaffAuthCheck, DaffAuthCheckFailure, DaffAuthCheckSuccess, DaffAuthFacade, DaffAuthGuardLogout, DaffAuthLogin, DaffAuthLoginActionTypes, DaffAuthLoginFacade, DaffAuthLoginFailure, DaffAuthLoginSuccess, DaffAuthLogout, DaffAuthLogoutFailure, DaffAuthLogoutSuccess, DaffAuthRegister, DaffAuthRegisterActionTypes, DaffAuthRegisterFacade, DaffAuthRegisterFailure, DaffAuthRegisterSuccess, DaffAuthResetPasswordActionTypes, DaffAuthResetPasswordFacade, DaffAuthServerSide, DaffAuthStateModule, DaffAuthStorageFailure, DaffResetPassword, DaffResetPasswordFailure, DaffResetPasswordLanding, DaffResetPasswordSuccess, DaffSendResetEmail, DaffSendResetEmailFailure, DaffSendResetEmailSuccess, daffAuthInitialState, daffAuthLoginInitialState, daffAuthLoginReducer, daffAuthReducer, daffAuthReducers, daffAuthRegisterInitialState, daffAuthRegisterReducer, daffAuthResetPasswordInitialState, daffAuthResetPasswordReducer, daffAuthStateDefaultConfig, getDaffAuthSelectors, provideDaffAuthStateConfig };
|
|
797
|
+
export { DAFF_AUTH_EXTRA_REDUCERS, DAFF_AUTH_STATE_CONFIG, DAFF_AUTH_STORE_FEATURE_KEY, DaffAuthActionTypes, DaffAuthCheck, DaffAuthCheckFailure, DaffAuthCheckSuccess, DaffAuthFacade, DaffAuthGuardLogout, DaffAuthLogin, DaffAuthLoginActionTypes, DaffAuthLoginFacade, DaffAuthLoginFailure, DaffAuthLoginSuccess, DaffAuthLogout, DaffAuthLogoutFailure, DaffAuthLogoutSuccess, DaffAuthRegister, DaffAuthRegisterActionTypes, DaffAuthRegisterFacade, DaffAuthRegisterFailure, DaffAuthRegisterSuccess, DaffAuthResetPasswordActionTypes, DaffAuthResetPasswordFacade, DaffAuthServerSide, DaffAuthStateModule, DaffAuthStorageFailure, DaffResetPassword, DaffResetPasswordFailure, DaffResetPasswordLanding, DaffResetPasswordSuccess, DaffSendResetEmail, DaffSendResetEmailFailure, DaffSendResetEmailSuccess, daffAuthInitialState, daffAuthLoginInitialState, daffAuthLoginReducer, daffAuthLoginSelectorFactory, daffAuthProvideExtraReducers, daffAuthReducer, daffAuthReducers, daffAuthRegisterInitialState, daffAuthRegisterReducer, daffAuthRegisterSelectorFactory, daffAuthResetPasswordInitialState, daffAuthResetPasswordReducer, daffAuthResetPasswordSelectorFactory, daffAuthSelectorFactory, daffAuthStateDefaultConfig, getDaffAuthSelectors, provideDaffAuthStateConfig };
|
|
826
798
|
//# sourceMappingURL=daffodil-auth-state.mjs.map
|