@igo2/auth 17.0.0-next.3 → 17.0.0-next.5
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/environment/environment.interface.d.ts +2 -2
- package/esm2022/environment/environment.interface.mjs +1 -1
- package/esm2022/form/auth-form.module.mjs +2 -24
- package/esm2022/form/public_api.mjs +1 -3
- package/esm2022/form/shared/index.mjs +1 -3
- package/esm2022/lib/auth.provider.mjs +22 -0
- package/esm2022/lib/shared/admin.guard.mjs +1 -1
- package/esm2022/lib/shared/auth-storage.interface.mjs +2 -0
- package/esm2022/lib/shared/auth-storage.service.mjs +100 -0
- package/esm2022/lib/shared/auth.guard.mjs +1 -1
- package/esm2022/lib/shared/auth.interceptor.mjs +1 -1
- package/esm2022/lib/shared/auth.interface.mjs +5 -2
- package/esm2022/lib/shared/auth.service.mjs +1 -1
- package/esm2022/lib/shared/index.mjs +3 -1
- package/esm2022/lib/shared/logged.guard.mjs +1 -1
- package/esm2022/lib/shared/profils.guard.mjs +1 -1
- package/esm2022/lib/shared/token.service.mjs +1 -1
- package/esm2022/microsoft/auth-microsoft.provider.mjs +43 -30
- package/esm2022/monitoring/auth-monitoring/auth-monitoring.provider.mjs +24 -0
- package/esm2022/monitoring/auth-monitoring/auth-monitoring.service.mjs +54 -0
- package/esm2022/monitoring/igo2-auth-monitoring.mjs +5 -0
- package/esm2022/monitoring/public_api.mjs +3 -0
- package/esm2022/public_api.mjs +3 -12
- package/fesm2022/igo2-auth-form.mjs +9 -120
- package/fesm2022/igo2-auth-form.mjs.map +1 -1
- package/fesm2022/igo2-auth-microsoft.mjs +44 -31
- package/fesm2022/igo2-auth-microsoft.mjs.map +1 -1
- package/fesm2022/igo2-auth-monitoring.mjs +81 -0
- package/fesm2022/igo2-auth-monitoring.mjs.map +1 -0
- package/fesm2022/igo2-auth.mjs +207 -162
- package/fesm2022/igo2-auth.mjs.map +1 -1
- package/form/auth-form.module.d.ts +0 -2
- package/form/public_api.d.ts +0 -2
- package/form/shared/index.d.ts +0 -2
- package/form/src/auth-form/auth-intern.theme.scss +19 -0
- package/form/src/auth-form.theme.scss +9 -0
- package/lib/auth.provider.d.ts +3 -0
- package/{form → lib}/shared/auth-storage.service.d.ts +2 -1
- package/lib/shared/auth.interface.d.ts +8 -0
- package/lib/shared/index.d.ts +2 -0
- package/locale/en.auth.json +29 -29
- package/locale/fr.auth.json +33 -33
- package/microsoft/auth-microsoft.provider.d.ts +2 -23
- package/{lib → monitoring}/auth-monitoring/auth-monitoring.service.d.ts +1 -1
- package/monitoring/index.d.ts +5 -0
- package/monitoring/public_api.d.ts +2 -0
- package/package.json +9 -3
- package/public_api.d.ts +2 -11
- package/esm2022/form/shared/auth-storage.interface.mjs +0 -2
- package/esm2022/form/shared/auth-storage.service.mjs +0 -98
- package/esm2022/lib/auth-monitoring/auth-monitoring.provider.mjs +0 -24
- package/esm2022/lib/auth-monitoring/auth-monitoring.service.mjs +0 -54
- /package/{form → lib}/shared/auth-storage.interface.d.ts +0 -0
- /package/{lib → monitoring}/auth-monitoring/auth-monitoring.provider.d.ts +0 -0
package/fesm2022/igo2-auth.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import * as i1 from '@angular/common/http';
|
|
2
|
-
import { HttpHeaders } from '@angular/common/http';
|
|
2
|
+
import { HttpHeaders, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { Injectable, Optional,
|
|
5
|
-
import
|
|
4
|
+
import { Injectable, Optional, makeEnvironmentProviders } from '@angular/core';
|
|
5
|
+
import { BaseStorage, StorageScope, StorageService } from '@igo2/core/storage';
|
|
6
6
|
import * as i2 from '@igo2/core/config';
|
|
7
7
|
import { ConfigService } from '@igo2/core/config';
|
|
8
|
+
import { jwtDecode } from 'jwt-decode';
|
|
9
|
+
import * as i3 from '@angular/router';
|
|
8
10
|
import * as i4 from '@igo2/core/language';
|
|
9
11
|
import * as i5 from '@igo2/core/message';
|
|
10
12
|
import { Base64 } from '@igo2/utils';
|
|
11
|
-
import { BehaviorSubject, of
|
|
13
|
+
import { BehaviorSubject, of } from 'rxjs';
|
|
12
14
|
import { tap, catchError, map } from 'rxjs/operators';
|
|
13
15
|
import { globalCacheBusterNotifier } from 'ts-cacheable';
|
|
14
|
-
import { jwtDecode } from 'jwt-decode';
|
|
15
16
|
import { Md5 } from 'ts-md5';
|
|
16
|
-
import { identifySentryUser, MONITORING_OPTIONS } from '@igo2/core/monitoring';
|
|
17
17
|
|
|
18
18
|
class TokenService {
|
|
19
19
|
injector;
|
|
@@ -216,129 +216,99 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImpor
|
|
|
216
216
|
type: Optional
|
|
217
217
|
}] }] });
|
|
218
218
|
|
|
219
|
-
class
|
|
219
|
+
class AuthStorageService extends BaseStorage {
|
|
220
|
+
http;
|
|
220
221
|
authService;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
tokenService;
|
|
223
|
+
constructor(config, http, authService, tokenService) {
|
|
224
|
+
super(config);
|
|
225
|
+
this.http = http;
|
|
224
226
|
this.authService = authService;
|
|
225
|
-
this.
|
|
226
|
-
this.
|
|
227
|
+
this.tokenService = tokenService;
|
|
228
|
+
this.authService.authenticate$.subscribe((isAuthenticated) => {
|
|
229
|
+
if (isAuthenticated && this.options.url) {
|
|
230
|
+
this.http
|
|
231
|
+
.get(this.options.url)
|
|
232
|
+
.subscribe((userIgo) => {
|
|
233
|
+
if (userIgo && userIgo.preference) {
|
|
234
|
+
for (const key of Object.keys(userIgo.preference)) {
|
|
235
|
+
const value = userIgo.preference[key];
|
|
236
|
+
super.set(key, value);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
});
|
|
227
242
|
}
|
|
228
|
-
|
|
229
|
-
if (
|
|
230
|
-
|
|
243
|
+
set(key, value, scope = StorageScope.LOCAL) {
|
|
244
|
+
if (scope === StorageScope.LOCAL &&
|
|
245
|
+
this.authService.authenticated &&
|
|
246
|
+
this.options.url) {
|
|
247
|
+
const preference = {};
|
|
248
|
+
preference[key] = value;
|
|
249
|
+
this.http.patch(this.options.url, { preference }).subscribe();
|
|
231
250
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
251
|
+
super.set(key, value, scope);
|
|
252
|
+
}
|
|
253
|
+
remove(key, scope = StorageScope.LOCAL) {
|
|
254
|
+
if (scope === StorageScope.LOCAL &&
|
|
255
|
+
this.authService.authenticated &&
|
|
256
|
+
this.options.url) {
|
|
257
|
+
const preference = {};
|
|
258
|
+
preference[key] = undefined;
|
|
259
|
+
this.http.patch(this.options.url, { preference }).subscribe();
|
|
236
260
|
}
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
authService;
|
|
251
|
-
config;
|
|
252
|
-
router;
|
|
253
|
-
constructor(authService, config, router) {
|
|
254
|
-
this.authService = authService;
|
|
255
|
-
this.config = config;
|
|
256
|
-
this.router = router;
|
|
257
|
-
}
|
|
258
|
-
canActivate(route, state) {
|
|
259
|
-
if (this.authService.authenticated) {
|
|
260
|
-
return true;
|
|
261
|
+
super.remove(key, scope);
|
|
262
|
+
}
|
|
263
|
+
clear(scope = StorageScope.LOCAL) {
|
|
264
|
+
if (scope === StorageScope.LOCAL &&
|
|
265
|
+
this.authService.authenticated &&
|
|
266
|
+
this.options.url) {
|
|
267
|
+
this.http
|
|
268
|
+
.patch(this.options.url, { preference: {} }, {
|
|
269
|
+
params: {
|
|
270
|
+
mergePreference: 'false'
|
|
271
|
+
}
|
|
272
|
+
})
|
|
273
|
+
.subscribe();
|
|
261
274
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
this.router.navigateByUrl(authConfig.loginRoute);
|
|
275
|
+
let token;
|
|
276
|
+
if (scope === StorageScope.LOCAL) {
|
|
277
|
+
token = this.tokenService.get();
|
|
266
278
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthGuard, providedIn: 'root' });
|
|
271
|
-
}
|
|
272
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthGuard, decorators: [{
|
|
273
|
-
type: Injectable,
|
|
274
|
-
args: [{
|
|
275
|
-
providedIn: 'root'
|
|
276
|
-
}]
|
|
277
|
-
}], ctorParameters: () => [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router }] });
|
|
278
|
-
|
|
279
|
-
class AdminGuard {
|
|
280
|
-
authService;
|
|
281
|
-
config;
|
|
282
|
-
router;
|
|
283
|
-
constructor(authService, config, router) {
|
|
284
|
-
this.authService = authService;
|
|
285
|
-
this.config = config;
|
|
286
|
-
this.router = router;
|
|
287
|
-
}
|
|
288
|
-
canActivate(route, state) {
|
|
289
|
-
if (this.authService.isAdmin) {
|
|
290
|
-
return true;
|
|
279
|
+
super.clear(scope);
|
|
280
|
+
if (token) {
|
|
281
|
+
this.tokenService.set(token);
|
|
291
282
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
this.
|
|
283
|
+
if (scope === StorageScope.LOCAL &&
|
|
284
|
+
this.authService.authenticated &&
|
|
285
|
+
this.options.url) {
|
|
286
|
+
this.http
|
|
287
|
+
.get(this.options.url)
|
|
288
|
+
.subscribe((userIgo) => {
|
|
289
|
+
if (userIgo && userIgo.preference) {
|
|
290
|
+
for (const key of Object.keys(userIgo.preference)) {
|
|
291
|
+
const value = userIgo.preference[key];
|
|
292
|
+
super.set(key, value);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
296
|
}
|
|
297
|
-
return false;
|
|
298
297
|
}
|
|
299
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type:
|
|
300
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type:
|
|
298
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthStorageService, deps: [{ token: i2.ConfigService }, { token: i1.HttpClient }, { token: AuthService }, { token: TokenService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
299
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthStorageService, providedIn: 'root' });
|
|
301
300
|
}
|
|
302
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type:
|
|
301
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthStorageService, decorators: [{
|
|
303
302
|
type: Injectable,
|
|
304
303
|
args: [{
|
|
305
304
|
providedIn: 'root'
|
|
306
305
|
}]
|
|
307
|
-
}], ctorParameters: () => [{ type:
|
|
306
|
+
}], ctorParameters: () => [{ type: i2.ConfigService }, { type: i1.HttpClient }, { type: AuthService }, { type: TokenService }] });
|
|
308
307
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
constructor(authService, config, router) {
|
|
314
|
-
this.authService = authService;
|
|
315
|
-
this.config = config;
|
|
316
|
-
this.router = router;
|
|
317
|
-
}
|
|
318
|
-
canActivate(_route, state) {
|
|
319
|
-
return this.authService.getProfils().pipe(map((profils) => {
|
|
320
|
-
const authConfig = this.config.getConfig('auth');
|
|
321
|
-
if (profils &&
|
|
322
|
-
profils.profils &&
|
|
323
|
-
profils.profils.some((v) => authConfig.profilsGuard.indexOf(v) !== -1)) {
|
|
324
|
-
return true;
|
|
325
|
-
}
|
|
326
|
-
this.authService.redirectUrl = state.url;
|
|
327
|
-
if (authConfig?.loginRoute) {
|
|
328
|
-
this.router.navigateByUrl(authConfig.loginRoute);
|
|
329
|
-
}
|
|
330
|
-
return false;
|
|
331
|
-
}));
|
|
332
|
-
}
|
|
333
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: ProfilsGuard, deps: [{ token: AuthService }, { token: i2.ConfigService }, { token: i3.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
334
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: ProfilsGuard, providedIn: 'root' });
|
|
335
|
-
}
|
|
336
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: ProfilsGuard, decorators: [{
|
|
337
|
-
type: Injectable,
|
|
338
|
-
args: [{
|
|
339
|
-
providedIn: 'root'
|
|
340
|
-
}]
|
|
341
|
-
}], ctorParameters: () => [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router }] });
|
|
308
|
+
var AuthFeatureKind;
|
|
309
|
+
(function (AuthFeatureKind) {
|
|
310
|
+
AuthFeatureKind[AuthFeatureKind["Microsoft"] = 0] = "Microsoft";
|
|
311
|
+
})(AuthFeatureKind || (AuthFeatureKind = {}));
|
|
342
312
|
|
|
343
313
|
class AuthInterceptor {
|
|
344
314
|
config;
|
|
@@ -493,71 +463,146 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImpor
|
|
|
493
463
|
}]
|
|
494
464
|
}], ctorParameters: () => [{ type: i2.ConfigService }, { type: TokenService }, { type: i1.HttpClient }] });
|
|
495
465
|
|
|
496
|
-
class
|
|
497
|
-
configService;
|
|
498
|
-
monitoringOptions;
|
|
499
|
-
injector;
|
|
500
|
-
// The AuthService need to be lazy provided because this service is provided in the APP_INITIALIZER
|
|
466
|
+
class LoggedGuard {
|
|
501
467
|
authService;
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
this.
|
|
506
|
-
|
|
507
|
-
|
|
468
|
+
config;
|
|
469
|
+
router;
|
|
470
|
+
constructor(authService, config, router) {
|
|
471
|
+
this.authService = authService;
|
|
472
|
+
this.config = config;
|
|
473
|
+
this.router = router;
|
|
474
|
+
}
|
|
475
|
+
canActivate(route, state) {
|
|
476
|
+
if (this.authService.logged) {
|
|
477
|
+
return true;
|
|
508
478
|
}
|
|
509
|
-
this.
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
const user = isAuthenticated ? this.authService.user : null;
|
|
516
|
-
this._identifyUser(user);
|
|
517
|
-
});
|
|
479
|
+
this.authService.redirectUrl = state.url;
|
|
480
|
+
const authConfig = this.config.getConfig('auth');
|
|
481
|
+
if (authConfig?.loginRoute) {
|
|
482
|
+
this.router.navigateByUrl(authConfig.loginRoute);
|
|
483
|
+
}
|
|
484
|
+
return false;
|
|
518
485
|
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
486
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: LoggedGuard, deps: [{ token: AuthService }, { token: i2.ConfigService }, { token: i3.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
487
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: LoggedGuard, providedIn: 'root' });
|
|
488
|
+
}
|
|
489
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: LoggedGuard, decorators: [{
|
|
490
|
+
type: Injectable,
|
|
491
|
+
args: [{
|
|
492
|
+
providedIn: 'root'
|
|
493
|
+
}]
|
|
494
|
+
}], ctorParameters: () => [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router }] });
|
|
495
|
+
|
|
496
|
+
class AuthGuard {
|
|
497
|
+
authService;
|
|
498
|
+
config;
|
|
499
|
+
router;
|
|
500
|
+
constructor(authService, config, router) {
|
|
501
|
+
this.authService = authService;
|
|
502
|
+
this.config = config;
|
|
503
|
+
this.router = router;
|
|
504
|
+
}
|
|
505
|
+
canActivate(route, state) {
|
|
506
|
+
if (this.authService.authenticated) {
|
|
507
|
+
return true;
|
|
508
|
+
}
|
|
509
|
+
this.authService.redirectUrl = state.url;
|
|
510
|
+
const authConfig = this.config.getConfig('auth');
|
|
511
|
+
if (authConfig?.loginRoute) {
|
|
512
|
+
this.router.navigateByUrl(authConfig.loginRoute);
|
|
526
513
|
}
|
|
514
|
+
return false;
|
|
527
515
|
}
|
|
528
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type:
|
|
529
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type:
|
|
516
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthGuard, deps: [{ token: AuthService }, { token: i2.ConfigService }, { token: i3.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
517
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthGuard, providedIn: 'root' });
|
|
530
518
|
}
|
|
531
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type:
|
|
519
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AuthGuard, decorators: [{
|
|
532
520
|
type: Injectable,
|
|
533
521
|
args: [{
|
|
534
522
|
providedIn: 'root'
|
|
535
523
|
}]
|
|
536
|
-
}], ctorParameters: () => [{ type: i2.ConfigService }, { type:
|
|
537
|
-
type: Optional
|
|
538
|
-
}, {
|
|
539
|
-
type: Inject,
|
|
540
|
-
args: [MONITORING_OPTIONS]
|
|
541
|
-
}] }, { type: i0.Injector }] });
|
|
524
|
+
}], ctorParameters: () => [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router }] });
|
|
542
525
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
526
|
+
class AdminGuard {
|
|
527
|
+
authService;
|
|
528
|
+
config;
|
|
529
|
+
router;
|
|
530
|
+
constructor(authService, config, router) {
|
|
531
|
+
this.authService = authService;
|
|
532
|
+
this.config = config;
|
|
533
|
+
this.router = router;
|
|
534
|
+
}
|
|
535
|
+
canActivate(route, state) {
|
|
536
|
+
if (this.authService.isAdmin) {
|
|
537
|
+
return true;
|
|
538
|
+
}
|
|
539
|
+
this.authService.redirectUrl = state.url;
|
|
540
|
+
const authConfig = this.config.getConfig('auth');
|
|
541
|
+
if (authConfig?.loginRoute) {
|
|
542
|
+
this.router.navigateByUrl(authConfig.loginRoute);
|
|
543
|
+
}
|
|
544
|
+
return false;
|
|
545
|
+
}
|
|
546
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AdminGuard, deps: [{ token: AuthService }, { token: i2.ConfigService }, { token: i3.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
547
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AdminGuard, providedIn: 'root' });
|
|
548
|
+
}
|
|
549
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: AdminGuard, decorators: [{
|
|
550
|
+
type: Injectable,
|
|
551
|
+
args: [{
|
|
552
|
+
providedIn: 'root'
|
|
553
|
+
}]
|
|
554
|
+
}], ctorParameters: () => [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router }] });
|
|
555
|
+
|
|
556
|
+
class ProfilsGuard {
|
|
557
|
+
authService;
|
|
558
|
+
config;
|
|
559
|
+
router;
|
|
560
|
+
constructor(authService, config, router) {
|
|
561
|
+
this.authService = authService;
|
|
562
|
+
this.config = config;
|
|
563
|
+
this.router = router;
|
|
564
|
+
}
|
|
565
|
+
canActivate(_route, state) {
|
|
566
|
+
return this.authService.getProfils().pipe(map((profils) => {
|
|
567
|
+
const authConfig = this.config.getConfig('auth');
|
|
568
|
+
if (profils &&
|
|
569
|
+
profils.profils &&
|
|
570
|
+
profils.profils.some((v) => authConfig.profilsGuard.indexOf(v) !== -1)) {
|
|
571
|
+
return true;
|
|
572
|
+
}
|
|
573
|
+
this.authService.redirectUrl = state.url;
|
|
574
|
+
if (authConfig?.loginRoute) {
|
|
575
|
+
this.router.navigateByUrl(authConfig.loginRoute);
|
|
576
|
+
}
|
|
577
|
+
return false;
|
|
578
|
+
}));
|
|
546
579
|
}
|
|
547
|
-
|
|
580
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: ProfilsGuard, deps: [{ token: AuthService }, { token: i2.ConfigService }, { token: i3.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
581
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: ProfilsGuard, providedIn: 'root' });
|
|
582
|
+
}
|
|
583
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: ProfilsGuard, decorators: [{
|
|
584
|
+
type: Injectable,
|
|
585
|
+
args: [{
|
|
586
|
+
providedIn: 'root'
|
|
587
|
+
}]
|
|
588
|
+
}], ctorParameters: () => [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router }] });
|
|
589
|
+
|
|
590
|
+
function provideAuthentification(...features) {
|
|
591
|
+
const providers = [
|
|
548
592
|
{
|
|
549
|
-
provide:
|
|
550
|
-
useClass:
|
|
551
|
-
|
|
593
|
+
provide: HTTP_INTERCEPTORS,
|
|
594
|
+
useClass: AuthInterceptor,
|
|
595
|
+
multi: true
|
|
552
596
|
},
|
|
553
|
-
// Force instantiate Tracing service to avoid require it in any constructor.
|
|
554
597
|
{
|
|
555
|
-
provide:
|
|
556
|
-
|
|
557
|
-
deps: [AuthMonitoringService],
|
|
558
|
-
multi: true
|
|
598
|
+
provide: StorageService,
|
|
599
|
+
useClass: AuthStorageService
|
|
559
600
|
}
|
|
560
601
|
];
|
|
602
|
+
for (const feature of features) {
|
|
603
|
+
providers.push(...feature.providers);
|
|
604
|
+
}
|
|
605
|
+
return makeEnvironmentProviders(providers);
|
|
561
606
|
}
|
|
562
607
|
|
|
563
608
|
/*
|
|
@@ -568,5 +613,5 @@ function provideAuthUserMonitoring(options) {
|
|
|
568
613
|
* Generated bundle index. Do not edit.
|
|
569
614
|
*/
|
|
570
615
|
|
|
571
|
-
export { AdminGuard, AuthGuard, AuthInterceptor,
|
|
616
|
+
export { AdminGuard, AuthFeatureKind, AuthGuard, AuthInterceptor, AuthService, AuthStorageService, LoggedGuard, ProfilsGuard, TokenService, provideAuthentification };
|
|
572
617
|
//# sourceMappingURL=igo2-auth.mjs.map
|