@igo2/auth 1.15.4 → 16.0.0-rc.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.
Files changed (76) hide show
  1. package/{esm2020 → esm2022}/igo2-auth.mjs +4 -4
  2. package/esm2022/lib/auth-form/auth-facebook.component.mjs +67 -0
  3. package/esm2022/lib/auth-form/auth-form.component.mjs +286 -0
  4. package/esm2022/lib/auth-form/auth-google.component.mjs +108 -0
  5. package/esm2022/lib/auth-form/auth-intern.component.mjs +134 -0
  6. package/esm2022/lib/auth-form/auth-microsoft.component.mjs +107 -0
  7. package/esm2022/lib/auth-form/auth-microsoftb2c.component.mjs +105 -0
  8. package/{esm2020 → esm2022}/lib/auth-form/index.mjs +5 -5
  9. package/{esm2020 → esm2022}/lib/auth-routing.module.mjs +24 -24
  10. package/{esm2020 → esm2022}/lib/auth.module.mjs +91 -91
  11. package/esm2022/lib/shared/admin.guard.mjs +39 -0
  12. package/esm2022/lib/shared/auth-microsoft.provider.mjs +86 -0
  13. package/esm2022/lib/shared/auth-msalBroadcastServiceb2c.service.mjs +47 -0
  14. package/esm2022/lib/shared/auth-msalServiceb2c.service..mjs +85 -0
  15. package/esm2022/lib/shared/auth.guard.mjs +38 -0
  16. package/esm2022/lib/shared/auth.interceptor.mjs +164 -0
  17. package/{esm2020 → esm2022}/lib/shared/auth.interface.mjs +2 -2
  18. package/esm2022/lib/shared/auth.service.mjs +168 -0
  19. package/esm2022/lib/shared/logged.guard.mjs +38 -0
  20. package/esm2022/lib/shared/profils.guard.mjs +43 -0
  21. package/esm2022/lib/shared/protected.directive.mjs +20 -0
  22. package/{esm2020 → esm2022}/lib/shared/storage.interface.mjs +1 -1
  23. package/esm2022/lib/shared/storage.service.mjs +99 -0
  24. package/esm2022/lib/shared/token.service.mjs +48 -0
  25. package/{esm2020 → esm2022}/public_api.mjs +18 -18
  26. package/{fesm2020 → fesm2022}/igo2-auth.mjs +1573 -1477
  27. package/fesm2022/igo2-auth.mjs.map +1 -0
  28. package/index.d.ts +5 -5
  29. package/lib/auth-form/auth-facebook.component.d.ts +18 -18
  30. package/lib/auth-form/auth-form.component.d.ts +42 -42
  31. package/lib/auth-form/auth-google.component.d.ts +24 -24
  32. package/lib/auth-form/auth-intern.component.d.ts +21 -21
  33. package/lib/auth-form/auth-microsoft.component.d.ts +23 -23
  34. package/lib/auth-form/auth-microsoftb2c.component.d.ts +23 -23
  35. package/lib/auth-form/index.d.ts +4 -4
  36. package/lib/auth-routing.module.d.ts +7 -7
  37. package/lib/auth.module.d.ts +23 -23
  38. package/lib/shared/admin.guard.d.ts +13 -13
  39. package/lib/shared/auth-microsoft.provider.d.ts +30 -30
  40. package/lib/shared/auth-msalBroadcastServiceb2c.service.d.ts +15 -15
  41. package/lib/shared/auth-msalServiceb2c.service..d.ts +33 -33
  42. package/lib/shared/auth.guard.d.ts +13 -13
  43. package/lib/shared/auth.interceptor.d.ts +24 -24
  44. package/lib/shared/auth.interface.d.ts +99 -99
  45. package/lib/shared/auth.service.d.ts +44 -44
  46. package/lib/shared/logged.guard.d.ts +13 -13
  47. package/lib/shared/profils.guard.d.ts +13 -13
  48. package/lib/shared/protected.directive.d.ts +8 -8
  49. package/lib/shared/storage.interface.d.ts +4 -4
  50. package/lib/shared/storage.service.d.ts +17 -18
  51. package/lib/shared/token.service.d.ts +15 -15
  52. package/locale/en.auth.json +28 -0
  53. package/locale/fr.auth.json +32 -0
  54. package/package.json +18 -25
  55. package/public_api.d.ts +15 -15
  56. package/esm2020/lib/auth-form/auth-facebook.component.mjs +0 -61
  57. package/esm2020/lib/auth-form/auth-form.component.mjs +0 -277
  58. package/esm2020/lib/auth-form/auth-google.component.mjs +0 -99
  59. package/esm2020/lib/auth-form/auth-intern.component.mjs +0 -119
  60. package/esm2020/lib/auth-form/auth-microsoft.component.mjs +0 -94
  61. package/esm2020/lib/auth-form/auth-microsoftb2c.component.mjs +0 -93
  62. package/esm2020/lib/shared/admin.guard.mjs +0 -33
  63. package/esm2020/lib/shared/auth-microsoft.provider.mjs +0 -84
  64. package/esm2020/lib/shared/auth-msalBroadcastServiceb2c.service.mjs +0 -38
  65. package/esm2020/lib/shared/auth-msalServiceb2c.service..mjs +0 -80
  66. package/esm2020/lib/shared/auth.guard.mjs +0 -32
  67. package/esm2020/lib/shared/auth.interceptor.mjs +0 -155
  68. package/esm2020/lib/shared/auth.service.mjs +0 -158
  69. package/esm2020/lib/shared/logged.guard.mjs +0 -32
  70. package/esm2020/lib/shared/profils.guard.mjs +0 -37
  71. package/esm2020/lib/shared/protected.directive.mjs +0 -19
  72. package/esm2020/lib/shared/storage.service.mjs +0 -91
  73. package/esm2020/lib/shared/token.service.mjs +0 -47
  74. package/fesm2015/igo2-auth.mjs +0 -1655
  75. package/fesm2015/igo2-auth.mjs.map +0 -1
  76. package/fesm2020/igo2-auth.mjs.map +0 -1
@@ -3,14 +3,14 @@ import { Injectable, Optional, EventEmitter, Component, ChangeDetectionStrategy,
3
3
  import * as i3 from '@angular/router';
4
4
  import { NavigationStart, RouterModule } from '@angular/router';
5
5
  import { tap, catchError, filter, takeUntil, map } from 'rxjs/operators';
6
+ import * as i2 from '@igo2/core';
7
+ import { ConfigService, BaseStorage, StorageScope, StorageService, IgoLanguageModule } from '@igo2/core';
6
8
  import * as i1 from '@angular/common/http';
7
9
  import { HttpHeaders, HTTP_INTERCEPTORS } from '@angular/common/http';
8
10
  import { BehaviorSubject, of, Subject, from } from 'rxjs';
9
11
  import { globalCacheBusterNotifier } from 'ts-cacheable';
10
12
  import { Base64 } from '@igo2/utils';
11
13
  import jwtDecode from 'jwt-decode';
12
- import * as i2 from '@igo2/core';
13
- import { ConfigService, StorageService, StorageScope, IgoLanguageModule } from '@igo2/core';
14
14
  import * as i1$1 from '@angular/common';
15
15
  import { CommonModule } from '@angular/common';
16
16
  import * as i5$1 from '@angular/material/button';
@@ -29,1523 +29,1619 @@ import * as i4 from '@angular/material/icon';
29
29
  import { MatIconModule } from '@angular/material/icon';
30
30
  import { Md5 } from 'ts-md5';
31
31
 
32
- class TokenService {
33
- constructor(injector) {
34
- this.injector = injector;
35
- }
36
- set(token) {
37
- localStorage.setItem(this.tokenKey, token);
38
- }
39
- remove() {
40
- localStorage.removeItem(this.tokenKey);
41
- }
42
- get() {
43
- return localStorage.getItem(this.tokenKey);
44
- }
45
- decode() {
46
- const token = this.get();
47
- if (!token) {
48
- return;
49
- }
50
- return jwtDecode(token);
51
- }
52
- isExpired() {
53
- const jwt = this.decode();
54
- const currentTime = new Date().getTime() / 1000;
55
- if (jwt && currentTime < jwt.exp) {
56
- return false;
57
- }
58
- return true;
59
- }
60
- get tokenKey() {
61
- const config = this.injector.get(ConfigService);
62
- this.options = config.getConfig('auth') || {};
63
- return this.options.tokenKey;
64
- }
65
- }
66
- TokenService.ɵfac = function TokenService_Factory(t) { return new (t || TokenService)(i0.ɵɵinject(i0.Injector)); };
67
- TokenService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: TokenService, factory: TokenService.ɵfac, providedIn: 'root' });
68
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TokenService, [{
69
- type: Injectable,
70
- args: [{
71
- providedIn: 'root'
72
- }]
32
+ class TokenService {
33
+ injector;
34
+ options;
35
+ tokenKey;
36
+ constructor(injector) {
37
+ this.injector = injector;
38
+ const config = this.injector.get(ConfigService);
39
+ this.options = config.getConfig('auth');
40
+ this.tokenKey = this.options?.tokenKey;
41
+ }
42
+ set(token) {
43
+ localStorage.setItem(this.tokenKey, token);
44
+ }
45
+ remove() {
46
+ localStorage.removeItem(this.tokenKey);
47
+ }
48
+ get() {
49
+ return localStorage.getItem(this.tokenKey);
50
+ }
51
+ decode() {
52
+ const token = this.get();
53
+ if (!token) {
54
+ return;
55
+ }
56
+ return jwtDecode(token);
57
+ }
58
+ isExpired() {
59
+ const jwt = this.decode();
60
+ const currentTime = new Date().getTime() / 1000;
61
+ if (jwt && currentTime < jwt.exp) {
62
+ return false;
63
+ }
64
+ return true;
65
+ }
66
+ static ɵfac = function TokenService_Factory(t) { return new (t || TokenService)(i0.ɵɵinject(i0.Injector)); };
67
+ static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: TokenService, factory: TokenService.ɵfac, providedIn: 'root' });
68
+ }
69
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TokenService, [{
70
+ type: Injectable,
71
+ args: [{
72
+ providedIn: 'root'
73
+ }]
73
74
  }], function () { return [{ type: i0.Injector }]; }, null); })();
74
75
 
75
- class AuthService {
76
- constructor(http, tokenService, config, languageService, messageService, router) {
77
- this.http = http;
78
- this.tokenService = tokenService;
79
- this.config = config;
80
- this.languageService = languageService;
81
- this.messageService = messageService;
82
- this.router = router;
83
- this.authenticate$ = new BehaviorSubject(undefined);
84
- this.logged$ = new BehaviorSubject(undefined);
85
- this.languageForce = false;
86
- this.anonymous = false;
87
- this.authenticate$.next(this.authenticated);
88
- this.authenticate$.subscribe((authenticated) => {
89
- this.logged$.next(authenticated);
90
- globalCacheBusterNotifier.next();
91
- });
92
- }
93
- get hasAuthService() {
94
- return this.config.getConfig('auth.url') !== undefined;
95
- }
96
- login(username, password) {
97
- const myHeader = new HttpHeaders({ 'Content-Type': 'application/json' });
98
- const body = {
99
- username,
100
- password: this.encodePassword(password)
101
- };
102
- return this.loginCall(body, myHeader);
103
- }
104
- loginWithToken(token, type, infosUser) {
105
- const myHeader = new HttpHeaders({ 'Content-Type': 'application/json' });
106
- const body = {
107
- token,
108
- typeConnection: type,
109
- infosUser
110
- };
111
- return this.loginCall(body, myHeader);
112
- }
113
- loginAnonymous() {
114
- this.anonymous = true;
115
- this.logged$.next(true);
116
- return of(true);
117
- }
118
- refresh() {
119
- const url = this.config.getConfig('auth.url');
120
- return this.http.post(`${url}/refresh`, {}).pipe(tap((data) => {
121
- this.tokenService.set(data.token);
122
- }), catchError((err) => {
123
- err.error.caught = true;
124
- throw err;
125
- }));
126
- }
127
- logout() {
128
- this.anonymous = false;
129
- this.tokenService.remove();
130
- this.authenticate$.next(false);
131
- return of(true);
132
- }
133
- isAuthenticated() {
134
- return !this.tokenService.isExpired();
135
- }
136
- getToken() {
137
- return this.tokenService.get();
138
- }
139
- decodeToken() {
140
- if (this.isAuthenticated()) {
141
- return this.tokenService.decode();
142
- }
143
- return false;
144
- }
145
- goToRedirectUrl() {
146
- if (!this.router) {
147
- return;
148
- }
149
- const redirectUrl = this.redirectUrl || this.router.url;
150
- const options = this.config.getConfig('auth') || {};
151
- if (redirectUrl === options.loginRoute) {
152
- const homeRoute = options.homeRoute || '/';
153
- this.router.navigateByUrl(homeRoute);
154
- }
155
- else if (redirectUrl) {
156
- this.router.navigateByUrl(redirectUrl);
157
- }
158
- }
159
- getUserInfo() {
160
- const url = this.config.getConfig('auth.url') + '/info';
161
- return this.http.get(url);
162
- }
163
- getProfils() {
164
- const url = this.config.getConfig('auth.url');
165
- return this.http.get(`${url}/profils`);
166
- }
167
- updateUser(user) {
168
- const url = this.config.getConfig('auth.url');
169
- return this.http.patch(url, user);
170
- }
171
- encodePassword(password) {
172
- return Base64.encode(password);
173
- }
174
- // authenticated or anonymous
175
- get logged() {
176
- return this.authenticated || this.isAnonymous;
177
- }
178
- get isAnonymous() {
179
- return this.anonymous;
180
- }
181
- get authenticated() {
182
- return this.isAuthenticated();
183
- }
184
- get isAdmin() {
185
- const token = this.decodeToken();
186
- if (token && token.user && token.user.isAdmin) {
187
- return true;
188
- }
189
- return false;
190
- }
191
- loginCall(body, headers) {
192
- const url = this.config.getConfig('auth.url');
193
- return this.http.post(`${url}/login`, body, { headers }).pipe(tap((data) => {
194
- this.tokenService.set(data.token);
195
- const tokenDecoded = this.decodeToken();
196
- if (tokenDecoded && tokenDecoded.user) {
197
- if (tokenDecoded.user.locale && !this.languageForce) {
198
- this.languageService.setLanguage(tokenDecoded.user.locale);
199
- }
200
- if (tokenDecoded.user.isExpired) {
201
- this.messageService.alert('igo.auth.error.Password expired');
202
- }
203
- }
204
- this.authenticate$.next(true);
205
- }), catchError((err) => {
206
- err.error.caught = true;
207
- throw err;
208
- }));
209
- }
210
- }
211
- AuthService.ɵfac = function AuthService_Factory(t) { return new (t || AuthService)(i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(TokenService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i2.LanguageService), i0.ɵɵinject(i2.MessageService), i0.ɵɵinject(i3.Router, 8)); };
212
- AuthService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthService, factory: AuthService.ɵfac, providedIn: 'root' });
213
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthService, [{
214
- type: Injectable,
215
- args: [{
216
- providedIn: 'root'
217
- }]
218
- }], function () { return [{ type: i1.HttpClient }, { type: TokenService }, { type: i2.ConfigService }, { type: i2.LanguageService }, { type: i2.MessageService }, { type: i3.Router, decorators: [{
219
- type: Optional
76
+ class AuthService {
77
+ http;
78
+ tokenService;
79
+ config;
80
+ languageService;
81
+ messageService;
82
+ router;
83
+ authenticate$ = new BehaviorSubject(undefined);
84
+ logged$ = new BehaviorSubject(undefined);
85
+ redirectUrl;
86
+ languageForce = false;
87
+ anonymous = false;
88
+ get hasAuthService() {
89
+ return this.config.getConfig('auth.url') !== undefined;
90
+ }
91
+ constructor(http, tokenService, config, languageService, messageService, router) {
92
+ this.http = http;
93
+ this.tokenService = tokenService;
94
+ this.config = config;
95
+ this.languageService = languageService;
96
+ this.messageService = messageService;
97
+ this.router = router;
98
+ this.authenticate$.next(this.authenticated);
99
+ this.authenticate$.subscribe((authenticated) => {
100
+ this.logged$.next(authenticated);
101
+ globalCacheBusterNotifier.next();
102
+ });
103
+ }
104
+ login(username, password) {
105
+ const myHeader = new HttpHeaders({ 'Content-Type': 'application/json' });
106
+ const body = {
107
+ username,
108
+ password: this.encodePassword(password)
109
+ };
110
+ return this.loginCall(body, myHeader);
111
+ }
112
+ loginWithToken(token, type, infosUser) {
113
+ const myHeader = new HttpHeaders({ 'Content-Type': 'application/json' });
114
+ const body = {
115
+ token,
116
+ typeConnection: type,
117
+ infosUser
118
+ };
119
+ return this.loginCall(body, myHeader);
120
+ }
121
+ loginAnonymous() {
122
+ this.anonymous = true;
123
+ this.logged$.next(true);
124
+ return of(true);
125
+ }
126
+ refresh() {
127
+ const url = this.config.getConfig('auth.url');
128
+ return this.http.post(`${url}/refresh`, {}).pipe(tap((data) => {
129
+ this.tokenService.set(data.token);
130
+ }), catchError((err) => {
131
+ err.error.caught = true;
132
+ throw err;
133
+ }));
134
+ }
135
+ logout() {
136
+ this.anonymous = false;
137
+ this.tokenService.remove();
138
+ this.authenticate$.next(false);
139
+ return of(true);
140
+ }
141
+ isAuthenticated() {
142
+ return !this.tokenService.isExpired();
143
+ }
144
+ getToken() {
145
+ return this.tokenService.get();
146
+ }
147
+ decodeToken() {
148
+ if (this.isAuthenticated()) {
149
+ return this.tokenService.decode();
150
+ }
151
+ return false;
152
+ }
153
+ goToRedirectUrl() {
154
+ if (!this.router) {
155
+ return;
156
+ }
157
+ const redirectUrl = this.redirectUrl || this.router.url;
158
+ const options = this.config.getConfig('auth') || {};
159
+ if (redirectUrl === options.loginRoute) {
160
+ const homeRoute = options.homeRoute || '/';
161
+ this.router.navigateByUrl(homeRoute);
162
+ }
163
+ else if (redirectUrl) {
164
+ this.router.navigateByUrl(redirectUrl);
165
+ }
166
+ }
167
+ getUserInfo() {
168
+ const url = this.config.getConfig('auth.url') + '/info';
169
+ return this.http.get(url);
170
+ }
171
+ getProfils() {
172
+ const url = this.config.getConfig('auth.url');
173
+ return this.http.get(`${url}/profils`);
174
+ }
175
+ updateUser(user) {
176
+ const url = this.config.getConfig('auth.url');
177
+ return this.http.patch(url, user);
178
+ }
179
+ encodePassword(password) {
180
+ return Base64.encode(password);
181
+ }
182
+ // authenticated or anonymous
183
+ get logged() {
184
+ return this.authenticated || this.isAnonymous;
185
+ }
186
+ get isAnonymous() {
187
+ return this.anonymous;
188
+ }
189
+ get authenticated() {
190
+ return this.isAuthenticated();
191
+ }
192
+ get isAdmin() {
193
+ const token = this.decodeToken();
194
+ if (token && token.user && token.user.isAdmin) {
195
+ return true;
196
+ }
197
+ return false;
198
+ }
199
+ loginCall(body, headers) {
200
+ const url = this.config.getConfig('auth.url');
201
+ return this.http.post(`${url}/login`, body, { headers }).pipe(tap((data) => {
202
+ this.tokenService.set(data.token);
203
+ const tokenDecoded = this.decodeToken();
204
+ if (tokenDecoded && tokenDecoded.user) {
205
+ if (tokenDecoded.user.locale && !this.languageForce) {
206
+ this.languageService.setLanguage(tokenDecoded.user.locale);
207
+ }
208
+ if (tokenDecoded.user.isExpired) {
209
+ this.messageService.alert('igo.auth.error.Password expired');
210
+ }
211
+ }
212
+ this.authenticate$.next(true);
213
+ }), catchError((err) => {
214
+ err.error.caught = true;
215
+ throw err;
216
+ }));
217
+ }
218
+ static ɵfac = function AuthService_Factory(t) { return new (t || AuthService)(i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(TokenService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i2.LanguageService), i0.ɵɵinject(i2.MessageService), i0.ɵɵinject(i3.Router, 8)); };
219
+ static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthService, factory: AuthService.ɵfac, providedIn: 'root' });
220
+ }
221
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthService, [{
222
+ type: Injectable,
223
+ args: [{
224
+ providedIn: 'root'
225
+ }]
226
+ }], function () { return [{ type: i1.HttpClient }, { type: TokenService }, { type: i2.ConfigService }, { type: i2.LanguageService }, { type: i2.MessageService }, { type: i3.Router, decorators: [{
227
+ type: Optional
220
228
  }] }]; }, null); })();
221
229
 
222
- class AuthGoogleComponent {
223
- constructor(authService, config, languageService, appRef) {
224
- this.authService = authService;
225
- this.config = config;
226
- this.languageService = languageService;
227
- this.appRef = appRef;
228
- this.login = new EventEmitter();
229
- this.options = this.config.getConfig('auth.google') || {};
230
- if (this.options.apiKey && this.options.clientId) {
231
- this.loadSDKGoogle();
232
- this.loadPlatform();
233
- }
234
- else {
235
- console.warn('Google authentification needs "apiKey" and "clientId" options');
236
- }
237
- }
238
- handleSignInClick() {
239
- window.gapi.auth2.getAuthInstance().signIn();
240
- }
241
- handleSignOutClick() {
242
- window.gapi.auth2.getAuthInstance().signOut();
243
- }
244
- handleClientLoad() {
245
- window.gapi.load('client:auth2', () => this.initClient());
246
- }
247
- initClient() {
248
- window.gapi.client
249
- .init({
250
- apiKey: this.options.apiKey,
251
- clientId: this.options.clientId,
252
- discoveryDocs: [
253
- 'https://people.googleapis.com/$discovery/rest?version=v1'
254
- ],
255
- scope: 'profile'
256
- })
257
- .then(() => {
258
- this.handleSignOutClick();
259
- this.updateTextButton();
260
- window.gapi.auth2.getAuthInstance().isSignedIn.listen(rep => {
261
- this.updateSigninStatus(rep);
262
- });
263
- });
264
- }
265
- updateSigninStatus(isSignedIn) {
266
- this.updateTextButton();
267
- if (isSignedIn) {
268
- this.loginGoogle(window.gapi.client.getToken().access_token);
269
- }
270
- }
271
- updateTextButton() {
272
- const btn = document.querySelector('span[id^="not_signed_"]');
273
- if (btn && this.languageService.getLanguage() !== 'en') {
274
- if (btn.innerHTML === 'Sign in with Google') {
275
- btn.innerHTML = this.languageService.translate.instant('igo.auth.google.login');
276
- }
277
- else if (btn.innerHTML === 'Signed in with Google') {
278
- btn.innerHTML = this.languageService.translate.instant('igo.auth.google.logged');
279
- }
280
- }
281
- }
282
- loginGoogle(token) {
283
- this.authService.loginWithToken(token, 'google').subscribe(() => {
284
- this.appRef.tick();
285
- this.login.emit(true);
286
- });
287
- }
288
- loadSDKGoogle() {
289
- const fjs = document.getElementsByTagName('script')[0];
290
- const js = document.createElement('script');
291
- js.id = 'google-jssdk';
292
- js.src = 'https://apis.google.com/js/api.js';
293
- js.onload = () => {
294
- this.handleClientLoad();
295
- };
296
- fjs.parentNode.insertBefore(js, fjs);
297
- }
298
- loadPlatform() {
299
- const fjs = document.getElementsByTagName('script')[0];
300
- const js = document.createElement('script');
301
- js.id = 'google-platform';
302
- js.src = 'https://apis.google.com/js/platform.js';
303
- fjs.parentNode.insertBefore(js, fjs);
304
- }
305
- }
306
- AuthGoogleComponent.ɵfac = function AuthGoogleComponent_Factory(t) { return new (t || AuthGoogleComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i2.LanguageService), i0.ɵɵdirectiveInject(i0.ApplicationRef)); };
307
- AuthGoogleComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthGoogleComponent, selectors: [["igo-auth-google"]], outputs: { login: "login" }, decls: 1, vars: 0, consts: [["data-height", "40", "data-width", "265", "data-longtitle", "true", 1, "g-signin2", "google-login-button"]], template: function AuthGoogleComponent_Template(rf, ctx) { if (rf & 1) {
308
- i0.ɵɵelement(0, "div", 0);
309
- } }, styles: ["[_nghost-%COMP%]{padding:10px 10px 10px 0;display:inline-block}.google-login-button[_ngcontent-%COMP%] .abcRioButton{color:#000000de}"], changeDetection: 0 });
310
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthGoogleComponent, [{
311
- type: Component,
312
- args: [{ selector: 'igo-auth-google', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"g-signin2 google-login-button\" data-height=\"40\" data-width=\"265\" data-longtitle=\"true\">\r\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block}.google-login-button ::ng-deep .abcRioButton{color:#000000de}\n"] }]
313
- }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i2.LanguageService }, { type: i0.ApplicationRef }]; }, { login: [{
314
- type: Output
230
+ class AuthGoogleComponent {
231
+ authService;
232
+ config;
233
+ languageService;
234
+ appRef;
235
+ options;
236
+ login = new EventEmitter();
237
+ constructor(authService, config, languageService, appRef) {
238
+ this.authService = authService;
239
+ this.config = config;
240
+ this.languageService = languageService;
241
+ this.appRef = appRef;
242
+ this.options = this.config.getConfig('auth.google');
243
+ if (this.options?.apiKey && this.options?.clientId) {
244
+ this.loadSDKGoogle();
245
+ this.loadPlatform();
246
+ }
247
+ else {
248
+ console.warn('Google authentification needs "apiKey" and "clientId" options');
249
+ }
250
+ }
251
+ handleSignInClick() {
252
+ window.gapi.auth2.getAuthInstance().signIn();
253
+ }
254
+ handleSignOutClick() {
255
+ window.gapi.auth2.getAuthInstance().signOut();
256
+ }
257
+ handleClientLoad() {
258
+ window.gapi.load('client:auth2', () => this.initClient());
259
+ }
260
+ initClient() {
261
+ window.gapi.client
262
+ .init({
263
+ apiKey: this.options?.apiKey,
264
+ clientId: this.options?.clientId,
265
+ discoveryDocs: [
266
+ 'https://people.googleapis.com/$discovery/rest?version=v1'
267
+ ],
268
+ scope: 'profile'
269
+ })
270
+ .then(() => {
271
+ this.handleSignOutClick();
272
+ this.updateTextButton();
273
+ window.gapi.auth2
274
+ .getAuthInstance()
275
+ .isSignedIn.listen((rep) => {
276
+ this.updateSigninStatus(rep);
277
+ });
278
+ });
279
+ }
280
+ updateSigninStatus(isSignedIn) {
281
+ this.updateTextButton();
282
+ if (isSignedIn) {
283
+ this.loginGoogle(window.gapi.client.getToken().access_token);
284
+ }
285
+ }
286
+ updateTextButton() {
287
+ const btn = document.querySelector('span[id^="not_signed_"]');
288
+ if (btn && this.languageService.getLanguage() !== 'en') {
289
+ if (btn.innerHTML === 'Sign in with Google') {
290
+ btn.innerHTML = this.languageService.translate.instant('igo.auth.google.login');
291
+ }
292
+ else if (btn.innerHTML === 'Signed in with Google') {
293
+ btn.innerHTML = this.languageService.translate.instant('igo.auth.google.logged');
294
+ }
295
+ }
296
+ }
297
+ loginGoogle(token) {
298
+ this.authService.loginWithToken(token, 'google').subscribe(() => {
299
+ this.appRef.tick();
300
+ this.login.emit(true);
301
+ });
302
+ }
303
+ loadSDKGoogle() {
304
+ const fjs = document.getElementsByTagName('script')[0];
305
+ const js = document.createElement('script');
306
+ js.id = 'google-jssdk';
307
+ js.src = 'https://apis.google.com/js/api.js';
308
+ js.onload = () => {
309
+ this.handleClientLoad();
310
+ };
311
+ fjs.parentNode.insertBefore(js, fjs);
312
+ }
313
+ loadPlatform() {
314
+ const fjs = document.getElementsByTagName('script')[0];
315
+ const js = document.createElement('script');
316
+ js.id = 'google-platform';
317
+ js.src = 'https://apis.google.com/js/platform.js';
318
+ fjs.parentNode.insertBefore(js, fjs);
319
+ }
320
+ static ɵfac = function AuthGoogleComponent_Factory(t) { return new (t || AuthGoogleComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i2.LanguageService), i0.ɵɵdirectiveInject(i0.ApplicationRef)); };
321
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthGoogleComponent, selectors: [["igo-auth-google"]], outputs: { login: "login" }, decls: 1, vars: 0, consts: [["data-height", "40", "data-width", "265", "data-longtitle", "true", 1, "g-signin2", "google-login-button"]], template: function AuthGoogleComponent_Template(rf, ctx) { if (rf & 1) {
322
+ i0.ɵɵelement(0, "div", 0);
323
+ } }, styles: ["[_nghost-%COMP%]{padding:10px 10px 10px 0;display:inline-block}.google-login-button[_ngcontent-%COMP%] .abcRioButton{color:#000000de}"], changeDetection: 0 });
324
+ }
325
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthGoogleComponent, [{
326
+ type: Component,
327
+ args: [{ selector: 'igo-auth-google', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\r\n class=\"g-signin2 google-login-button\"\r\n data-height=\"40\"\r\n data-width=\"265\"\r\n data-longtitle=\"true\"\r\n></div>\r\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block}.google-login-button ::ng-deep .abcRioButton{color:#000000de}\n"] }]
328
+ }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i2.LanguageService }, { type: i0.ApplicationRef }]; }, { login: [{
329
+ type: Output
315
330
  }] }); })();
316
331
 
317
- function AuthInternComponent_button_12_Template(rf, ctx) { if (rf & 1) {
318
- const _r3 = i0.ɵɵgetCurrentView();
319
- i0.ɵɵelementStart(0, "button", 7);
320
- i0.ɵɵlistener("click", function AuthInternComponent_button_12_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r3); const ctx_r2 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r2.loginAnonymous()); });
321
- i0.ɵɵtext(1);
322
- i0.ɵɵpipe(2, "translate");
323
- i0.ɵɵelementEnd();
324
- } if (rf & 2) {
325
- const ctx_r0 = i0.ɵɵnextContext();
326
- i0.ɵɵproperty("disabled", ctx_r0.loading);
327
- i0.ɵɵadvance(1);
328
- i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 2, "igo.auth.accessAnonymous"), " ");
329
- } }
330
- function AuthInternComponent_div_13_Template(rf, ctx) { if (rf & 1) {
331
- i0.ɵɵelementStart(0, "div");
332
- i0.ɵɵelement(1, "br");
333
- i0.ɵɵelementStart(2, "font", 8);
334
- i0.ɵɵtext(3);
335
- i0.ɵɵelementEnd()();
336
- } if (rf & 2) {
337
- const ctx_r1 = i0.ɵɵnextContext();
338
- i0.ɵɵadvance(3);
339
- i0.ɵɵtextInterpolate(ctx_r1.error);
340
- } }
341
- class AuthInternComponent {
342
- constructor(auth, languageService, fb) {
343
- this.auth = auth;
344
- this.languageService = languageService;
345
- this._allowAnonymous = true;
346
- this.error = '';
347
- this.loading = false;
348
- this.login = new EventEmitter();
349
- this.form = fb.group({
350
- username: ['', Validators.required],
351
- password: ['', Validators.required]
352
- });
353
- }
354
- get allowAnonymous() {
355
- return this._allowAnonymous;
356
- }
357
- set allowAnonymous(value) {
358
- this._allowAnonymous = value;
359
- }
360
- loginUser(values) {
361
- this.loading = true;
362
- this.auth.login(values.username, values.password).subscribe(() => {
363
- this.login.emit(true);
364
- this.loading = false;
365
- }, (error) => {
366
- try {
367
- this.languageService.translate
368
- .get('igo.auth.error.' + error.error.message)
369
- .subscribe(errorMsg => (this.error = errorMsg));
370
- }
371
- catch (e) {
372
- this.error = error.error.message;
373
- }
374
- this.loading = false;
375
- });
376
- return false;
377
- }
378
- loginAnonymous() {
379
- this.auth.loginAnonymous().subscribe(() => {
380
- this.login.emit(true);
381
- });
382
- }
383
- }
384
- AuthInternComponent.ɵfac = function AuthInternComponent_Factory(t) { return new (t || AuthInternComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.LanguageService), i0.ɵɵdirectiveInject(i3$1.UntypedFormBuilder)); };
385
- AuthInternComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthInternComponent, selectors: [["igo-auth-intern"]], inputs: { allowAnonymous: "allowAnonymous" }, outputs: { login: "login" }, decls: 14, vars: 12, consts: [["role", "form", 3, "formGroup", "ngSubmit"], [1, "full-width"], ["matInput", "", "required", "", "formControlName", "username", 3, "placeholder"], ["matInput", "", "required", "", "type", "password", "formControlName", "password", 3, "placeholder"], ["mat-raised-button", "", "type", "submit"], ["mat-raised-button", "", "class", "anonymous", "type", "button", 3, "disabled", "click", 4, "ngIf"], [4, "ngIf"], ["mat-raised-button", "", "type", "button", 1, "anonymous", 3, "disabled", "click"], ["size", "3", "color", "red"]], template: function AuthInternComponent_Template(rf, ctx) { if (rf & 1) {
386
- i0.ɵɵelementStart(0, "form", 0);
387
- i0.ɵɵlistener("ngSubmit", function AuthInternComponent_Template_form_ngSubmit_0_listener() { return ctx.loginUser(ctx.form.value); });
388
- i0.ɵɵelementStart(1, "div")(2, "mat-form-field", 1);
389
- i0.ɵɵelement(3, "input", 2);
390
- i0.ɵɵpipe(4, "translate");
391
- i0.ɵɵelementEnd()();
392
- i0.ɵɵelementStart(5, "div")(6, "mat-form-field", 1);
393
- i0.ɵɵelement(7, "input", 3);
394
- i0.ɵɵpipe(8, "translate");
395
- i0.ɵɵelementEnd()();
396
- i0.ɵɵelementStart(9, "button", 4);
397
- i0.ɵɵtext(10);
398
- i0.ɵɵpipe(11, "translate");
399
- i0.ɵɵelementEnd();
400
- i0.ɵɵtemplate(12, AuthInternComponent_button_12_Template, 3, 4, "button", 5);
401
- i0.ɵɵtemplate(13, AuthInternComponent_div_13_Template, 4, 1, "div", 6);
402
- i0.ɵɵelementEnd();
403
- } if (rf & 2) {
404
- i0.ɵɵproperty("formGroup", ctx.form);
405
- i0.ɵɵadvance(3);
406
- i0.ɵɵpropertyInterpolate("placeholder", i0.ɵɵpipeBind1(4, 6, "igo.auth.user"));
407
- i0.ɵɵadvance(4);
408
- i0.ɵɵpropertyInterpolate("placeholder", i0.ɵɵpipeBind1(8, 8, "igo.auth.password"));
409
- i0.ɵɵadvance(3);
410
- i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(11, 10, "igo.auth.login"));
411
- i0.ɵɵadvance(2);
412
- i0.ɵɵproperty("ngIf", ctx.allowAnonymous);
413
- i0.ɵɵadvance(1);
414
- i0.ɵɵproperty("ngIf", ctx.error);
415
- } }, dependencies: [i1$1.NgIf, i3$1.ɵNgNoValidate, i3$1.DefaultValueAccessor, i3$1.NgControlStatus, i3$1.NgControlStatusGroup, i3$1.RequiredValidator, i3$1.FormGroupDirective, i3$1.FormControlName, i5.MatFormField, i6.MatInput, i5$1.MatButton, i6$1.TranslatePipe], styles: [".full-width[_ngcontent-%COMP%]{width:100%}.anonymous[_ngcontent-%COMP%]{margin-left:10px}"] });
416
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthInternComponent, [{
417
- type: Component,
418
- args: [{ selector: 'igo-auth-intern', changeDetection: ChangeDetectionStrategy.Default, template: "<form [formGroup]=\"form\" role=\"form\" (ngSubmit)=\"loginUser(form.value)\">\r\n <div>\r\n <mat-form-field class=\"full-width\">\r\n <input matInput required placeholder=\"{{'igo.auth.user' | translate}}\" formControlName=\"username\">\r\n </mat-form-field>\r\n </div>\r\n\r\n <div>\r\n <mat-form-field class=\"full-width\">\r\n <input matInput required type=\"password\" placeholder=\"{{'igo.auth.password' | translate}}\" formControlName=\"password\">\r\n </mat-form-field>\r\n </div>\r\n\r\n <button mat-raised-button type=\"submit\">{{'igo.auth.login' | translate}}</button>\r\n <button *ngIf=\"allowAnonymous\" mat-raised-button class=\"anonymous\" type=\"button\" [disabled]=\"loading\" (click)=\"loginAnonymous()\">\r\n {{'igo.auth.accessAnonymous' | translate }}\r\n </button>\r\n <div *ngIf=\"error\">\r\n <br/>\r\n <font size=\"3\" color=\"red\">{{error}}</font>\r\n </div>\r\n</form>\r\n\r\n<!--\r\nThis part was removed from the below line to fix Angular issue 30616 : [disabled]=\"!form.valid || loading\r\n <button mat-raised-button type=\"submit\" [disabled]=\"!form.valid || loading\">{{'igo.auth.login' | translate}}</button>*/\r\n-->\r\n", styles: [".full-width{width:100%}.anonymous{margin-left:10px}\n"] }]
419
- }], function () { return [{ type: AuthService }, { type: i2.LanguageService }, { type: i3$1.UntypedFormBuilder }]; }, { allowAnonymous: [{
420
- type: Input
421
- }], login: [{
422
- type: Output
332
+ function AuthInternComponent_button_18_Template(rf, ctx) { if (rf & 1) {
333
+ const _r3 = i0.ɵɵgetCurrentView();
334
+ i0.ɵɵelementStart(0, "button", 7);
335
+ i0.ɵɵlistener("click", function AuthInternComponent_button_18_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r3); const ctx_r2 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r2.loginAnonymous()); });
336
+ i0.ɵɵtext(1);
337
+ i0.ɵɵpipe(2, "translate");
338
+ i0.ɵɵelementEnd();
339
+ } if (rf & 2) {
340
+ const ctx_r0 = i0.ɵɵnextContext();
341
+ i0.ɵɵproperty("disabled", ctx_r0.loading);
342
+ i0.ɵɵadvance(1);
343
+ i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 2, "igo.auth.accessAnonymous"), " ");
344
+ } }
345
+ function AuthInternComponent_div_19_Template(rf, ctx) { if (rf & 1) {
346
+ i0.ɵɵelementStart(0, "div");
347
+ i0.ɵɵelement(1, "br");
348
+ i0.ɵɵelementStart(2, "font", 8);
349
+ i0.ɵɵtext(3);
350
+ i0.ɵɵelementEnd()();
351
+ } if (rf & 2) {
352
+ const ctx_r1 = i0.ɵɵnextContext();
353
+ i0.ɵɵadvance(3);
354
+ i0.ɵɵtextInterpolate(ctx_r1.error);
355
+ } }
356
+ class AuthInternComponent {
357
+ auth;
358
+ languageService;
359
+ get allowAnonymous() {
360
+ return this._allowAnonymous;
361
+ }
362
+ set allowAnonymous(value) {
363
+ this._allowAnonymous = value;
364
+ }
365
+ _allowAnonymous = true;
366
+ error = '';
367
+ form;
368
+ loading = false;
369
+ login = new EventEmitter();
370
+ constructor(auth, languageService, fb) {
371
+ this.auth = auth;
372
+ this.languageService = languageService;
373
+ this.form = fb.group({
374
+ username: ['', Validators.required],
375
+ password: ['', Validators.required]
376
+ });
377
+ }
378
+ loginUser(values) {
379
+ this.loading = true;
380
+ this.auth.login(values.username, values.password).subscribe(() => {
381
+ this.login.emit(true);
382
+ this.loading = false;
383
+ }, (error) => {
384
+ try {
385
+ this.languageService.translate
386
+ .get('igo.auth.error.' + error.error.message)
387
+ .subscribe((errorMsg) => (this.error = errorMsg));
388
+ }
389
+ catch (e) {
390
+ this.error = error.error.message;
391
+ }
392
+ this.loading = false;
393
+ });
394
+ return false;
395
+ }
396
+ loginAnonymous() {
397
+ this.auth.loginAnonymous().subscribe(() => {
398
+ this.login.emit(true);
399
+ });
400
+ }
401
+ static ɵfac = function AuthInternComponent_Factory(t) { return new (t || AuthInternComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.LanguageService), i0.ɵɵdirectiveInject(i3$1.UntypedFormBuilder)); };
402
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthInternComponent, selectors: [["igo-auth-intern"]], inputs: { allowAnonymous: "allowAnonymous" }, outputs: { login: "login" }, decls: 20, vars: 18, consts: [["role", "form", 3, "formGroup", "ngSubmit"], [1, "full-width"], ["matInput", "", "required", "", "formControlName", "username", 3, "placeholder"], ["matInput", "", "required", "", "type", "password", "formControlName", "password", 3, "placeholder"], ["mat-raised-button", "", "type", "submit"], ["mat-raised-button", "", "class", "anonymous", "type", "button", 3, "disabled", "click", 4, "ngIf"], [4, "ngIf"], ["mat-raised-button", "", "type", "button", 1, "anonymous", 3, "disabled", "click"], ["size", "3", "color", "red"]], template: function AuthInternComponent_Template(rf, ctx) { if (rf & 1) {
403
+ i0.ɵɵelementStart(0, "form", 0);
404
+ i0.ɵɵlistener("ngSubmit", function AuthInternComponent_Template_form_ngSubmit_0_listener() { return ctx.loginUser(ctx.form.value); });
405
+ i0.ɵɵelementStart(1, "div")(2, "mat-form-field", 1)(3, "mat-label");
406
+ i0.ɵɵtext(4);
407
+ i0.ɵɵpipe(5, "translate");
408
+ i0.ɵɵelementEnd();
409
+ i0.ɵɵelement(6, "input", 2);
410
+ i0.ɵɵpipe(7, "translate");
411
+ i0.ɵɵelementEnd()();
412
+ i0.ɵɵelementStart(8, "div")(9, "mat-form-field", 1)(10, "mat-label");
413
+ i0.ɵɵtext(11);
414
+ i0.ɵɵpipe(12, "translate");
415
+ i0.ɵɵelementEnd();
416
+ i0.ɵɵelement(13, "input", 3);
417
+ i0.ɵɵpipe(14, "translate");
418
+ i0.ɵɵelementEnd()();
419
+ i0.ɵɵelementStart(15, "button", 4);
420
+ i0.ɵɵtext(16);
421
+ i0.ɵɵpipe(17, "translate");
422
+ i0.ɵɵelementEnd();
423
+ i0.ɵɵtemplate(18, AuthInternComponent_button_18_Template, 3, 4, "button", 5);
424
+ i0.ɵɵtemplate(19, AuthInternComponent_div_19_Template, 4, 1, "div", 6);
425
+ i0.ɵɵelementEnd();
426
+ } if (rf & 2) {
427
+ i0.ɵɵproperty("formGroup", ctx.form);
428
+ i0.ɵɵadvance(4);
429
+ i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(5, 8, "igo.auth.user"));
430
+ i0.ɵɵadvance(2);
431
+ i0.ɵɵpropertyInterpolate("placeholder", i0.ɵɵpipeBind1(7, 10, "igo.auth.user"));
432
+ i0.ɵɵadvance(5);
433
+ i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(12, 12, "igo.auth.password"));
434
+ i0.ɵɵadvance(2);
435
+ i0.ɵɵpropertyInterpolate("placeholder", i0.ɵɵpipeBind1(14, 14, "igo.auth.password"));
436
+ i0.ɵɵadvance(3);
437
+ i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(17, 16, "igo.auth.login"), " ");
438
+ i0.ɵɵadvance(2);
439
+ i0.ɵɵproperty("ngIf", ctx.allowAnonymous);
440
+ i0.ɵɵadvance(1);
441
+ i0.ɵɵproperty("ngIf", ctx.error);
442
+ } }, dependencies: [i1$1.NgIf, i3$1.ɵNgNoValidate, i3$1.DefaultValueAccessor, i3$1.NgControlStatus, i3$1.NgControlStatusGroup, i3$1.RequiredValidator, i3$1.FormGroupDirective, i3$1.FormControlName, i5.MatFormField, i5.MatLabel, i6.MatInput, i5$1.MatButton, i6$1.TranslatePipe], styles: [".full-width[_ngcontent-%COMP%]{width:100%}.anonymous[_ngcontent-%COMP%]{margin-left:10px}"] });
443
+ }
444
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthInternComponent, [{
445
+ type: Component,
446
+ args: [{ selector: 'igo-auth-intern', changeDetection: ChangeDetectionStrategy.Default, template: "<form [formGroup]=\"form\" role=\"form\" (ngSubmit)=\"loginUser(form.value)\">\r\n <div>\r\n <mat-form-field class=\"full-width\">\r\n <mat-label>{{ 'igo.auth.user' | translate }}</mat-label>\r\n <input\r\n matInput\r\n required\r\n placeholder=\"{{ 'igo.auth.user' | translate }}\"\r\n formControlName=\"username\"\r\n />\r\n </mat-form-field>\r\n </div>\r\n\r\n <div>\r\n <mat-form-field class=\"full-width\">\r\n <mat-label>{{ 'igo.auth.password' | translate }}</mat-label>\r\n <input\r\n matInput\r\n required\r\n type=\"password\"\r\n placeholder=\"{{ 'igo.auth.password' | translate }}\"\r\n formControlName=\"password\"\r\n />\r\n </mat-form-field>\r\n </div>\r\n\r\n <button mat-raised-button type=\"submit\">\r\n {{ 'igo.auth.login' | translate }}\r\n </button>\r\n <button\r\n *ngIf=\"allowAnonymous\"\r\n mat-raised-button\r\n class=\"anonymous\"\r\n type=\"button\"\r\n [disabled]=\"loading\"\r\n (click)=\"loginAnonymous()\"\r\n >\r\n {{ 'igo.auth.accessAnonymous' | translate }}\r\n </button>\r\n <div *ngIf=\"error\">\r\n <br />\r\n <font size=\"3\" color=\"red\">{{ error }}</font>\r\n </div>\r\n</form>\r\n", styles: [".full-width{width:100%}.anonymous{margin-left:10px}\n"] }]
447
+ }], function () { return [{ type: AuthService }, { type: i2.LanguageService }, { type: i3$1.UntypedFormBuilder }]; }, { allowAnonymous: [{
448
+ type: Input
449
+ }], login: [{
450
+ type: Output
423
451
  }] }); })();
424
452
 
425
- class AuthFacebookComponent {
426
- constructor(authService, config, appRef) {
427
- this.authService = authService;
428
- this.config = config;
429
- this.appRef = appRef;
430
- this.login = new EventEmitter();
431
- this.options = this.config.getConfig('auth.facebook') || {};
432
- if (this.options.appId) {
433
- this.loadSDKFacebook();
434
- }
435
- else {
436
- console.warn('Facebook authentification needs "appId" option');
437
- }
438
- }
439
- subscribeEvents() {
440
- window.FB.Event.subscribe('auth.statusChange', rep => {
441
- this.statusChangeCallback(rep);
442
- });
443
- }
444
- statusChangeCallback(response) {
445
- if (response.status === 'connected') {
446
- const accessToken = response.authResponse.accessToken;
447
- this.loginFacebook(accessToken);
448
- }
449
- }
450
- loginFacebook(token) {
451
- this.authService.loginWithToken(token, 'facebook').subscribe(() => {
452
- this.appRef.tick();
453
- this.login.emit(true);
454
- });
455
- }
456
- loadSDKFacebook() {
457
- if (document.getElementById('facebook-jssdk')) {
458
- return;
459
- }
460
- const urlSDK = 'https://connect.facebook.net/fr_CA/sdk.js#xfbml=1&version=v2.9';
461
- const fjs = document.getElementsByTagName('script')[0];
462
- const js = document.createElement('script');
463
- js.id = 'facebook-jssdk';
464
- js.src = `${urlSDK}&appId=${this.options.appId}`;
465
- js.onload = () => {
466
- this.subscribeEvents();
467
- };
468
- fjs.parentNode.insertBefore(js, fjs);
469
- }
470
- }
471
- AuthFacebookComponent.ɵfac = function AuthFacebookComponent_Factory(t) { return new (t || AuthFacebookComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i0.ApplicationRef)); };
472
- AuthFacebookComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthFacebookComponent, selectors: [["igo-auth-facebook"]], outputs: { login: "login" }, decls: 1, vars: 0, consts: [["scope", "public_profile,email", "data-max-rows", "1", "data-size", "large", "data-button-type", "login_with", "data-show-faces", "false", "data-auto-logout-link", "false", "data-use-continue-as", "false", 1, "fb-login-button"]], template: function AuthFacebookComponent_Template(rf, ctx) { if (rf & 1) {
473
- i0.ɵɵelement(0, "div", 0);
474
- } }, styles: ["[_nghost-%COMP%]{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-3px}"], changeDetection: 0 });
475
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthFacebookComponent, [{
476
- type: Component,
477
- args: [{ selector: 'igo-auth-facebook', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div scope=\"public_profile,email\"\r\n class=\"fb-login-button\" data-max-rows=\"1\" data-size=\"large\"\r\n data-button-type=\"login_with\" data-show-faces=\"false\"\r\n data-auto-logout-link=\"false\" data-use-continue-as=\"false\">\r\n</div>\r\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-3px}\n"] }]
478
- }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i0.ApplicationRef }]; }, { login: [{
479
- type: Output
453
+ class AuthFacebookComponent {
454
+ authService;
455
+ config;
456
+ appRef;
457
+ options;
458
+ login = new EventEmitter();
459
+ constructor(authService, config, appRef) {
460
+ this.authService = authService;
461
+ this.config = config;
462
+ this.appRef = appRef;
463
+ this.options = this.config.getConfig('auth.facebook');
464
+ if (this.options?.appId) {
465
+ this.loadSDKFacebook();
466
+ }
467
+ else {
468
+ console.warn('Facebook authentification needs "appId" option');
469
+ }
470
+ }
471
+ subscribeEvents() {
472
+ window.FB.Event.subscribe('auth.statusChange', (rep) => {
473
+ this.statusChangeCallback(rep);
474
+ });
475
+ }
476
+ statusChangeCallback(response) {
477
+ if (response.status === 'connected') {
478
+ const accessToken = response.authResponse.accessToken;
479
+ this.loginFacebook(accessToken);
480
+ }
481
+ }
482
+ loginFacebook(token) {
483
+ this.authService.loginWithToken(token, 'facebook').subscribe(() => {
484
+ this.appRef.tick();
485
+ this.login.emit(true);
486
+ });
487
+ }
488
+ loadSDKFacebook() {
489
+ if (document.getElementById('facebook-jssdk')) {
490
+ return;
491
+ }
492
+ const urlSDK = 'https://connect.facebook.net/fr_CA/sdk.js#xfbml=1&version=v2.9';
493
+ const fjs = document.getElementsByTagName('script')[0];
494
+ const js = document.createElement('script');
495
+ js.id = 'facebook-jssdk';
496
+ js.src = `${urlSDK}&appId=${this.options?.appId}`;
497
+ js.onload = () => {
498
+ this.subscribeEvents();
499
+ };
500
+ fjs.parentNode.insertBefore(js, fjs);
501
+ }
502
+ static ɵfac = function AuthFacebookComponent_Factory(t) { return new (t || AuthFacebookComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i0.ApplicationRef)); };
503
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthFacebookComponent, selectors: [["igo-auth-facebook"]], outputs: { login: "login" }, decls: 1, vars: 0, consts: [["scope", "public_profile,email", "data-max-rows", "1", "data-size", "large", "data-button-type", "login_with", "data-show-faces", "false", "data-auto-logout-link", "false", "data-use-continue-as", "false", 1, "fb-login-button"]], template: function AuthFacebookComponent_Template(rf, ctx) { if (rf & 1) {
504
+ i0.ɵɵelement(0, "div", 0);
505
+ } }, styles: ["[_nghost-%COMP%]{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-3px}"], changeDetection: 0 });
506
+ }
507
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthFacebookComponent, [{
508
+ type: Component,
509
+ args: [{ selector: 'igo-auth-facebook', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\r\n scope=\"public_profile,email\"\r\n class=\"fb-login-button\"\r\n data-max-rows=\"1\"\r\n data-size=\"large\"\r\n data-button-type=\"login_with\"\r\n data-show-faces=\"false\"\r\n data-auto-logout-link=\"false\"\r\n data-use-continue-as=\"false\"\r\n></div>\r\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-3px}\n"] }]
510
+ }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i0.ApplicationRef }]; }, { login: [{
511
+ type: Output
480
512
  }] }); })();
481
513
 
482
- class AuthMicrosoftComponent {
483
- constructor(authService, config, appRef, msalService, msalGuardConfig) {
484
- this.authService = authService;
485
- this.config = config;
486
- this.appRef = appRef;
487
- this.msalService = msalService;
488
- this.msalGuardConfig = msalGuardConfig;
489
- this._destroying$ = new Subject();
490
- this.login = new EventEmitter();
491
- this.options = this.config.getConfig('auth.microsoft') || {};
492
- this.msalService.instance = new PublicClientApplication({
493
- auth: this.options,
494
- cache: {
495
- cacheLocation: 'sessionStorage'
496
- }
497
- });
498
- this.broadcastService = new MsalBroadcastService(this.msalService.instance, this.msalService);
499
- if (this.options.clientId) {
500
- this.broadcastService.inProgress$
501
- .pipe(filter((status) => status === InteractionStatus.None), takeUntil(this._destroying$))
502
- .subscribe(() => {
503
- this.checkAccount();
504
- });
505
- }
506
- else {
507
- console.warn('Microsoft authentification needs "clientId" option');
508
- }
509
- }
510
- loginMicrosoft() {
511
- this.msalService.loginPopup({ ...this.getConf().authRequest })
512
- .subscribe((response) => {
513
- this.msalService.instance.setActiveAccount(response.account);
514
- this.checkAccount();
515
- });
516
- }
517
- checkAccount() {
518
- this.msalService.instance
519
- .acquireTokenSilent(this.getConf().authRequest)
520
- .then((response) => {
521
- const tokenAccess = response.accessToken;
522
- const tokenId = response.idToken;
523
- this.authService.loginWithToken(tokenAccess, 'microsoft', { tokenId }).subscribe(() => {
524
- this.appRef.tick();
525
- this.login.emit(true);
526
- });
527
- })
528
- .catch(async (error) => {
529
- if (error instanceof InteractionRequiredAuthError) {
530
- // fallback to interaction when silent call fails
531
- return this.msalService.acquireTokenPopup(this.getConf().authRequest);
532
- }
533
- console.log(error);
534
- }).catch(error => {
535
- console.log('Silent token fails');
536
- });
537
- }
538
- getConf() {
539
- return this.msalGuardConfig.filter(conf => conf.type === 'add')[0];
540
- }
541
- }
542
- AuthMicrosoftComponent.ɵfac = function AuthMicrosoftComponent_Factory(t) { return new (t || AuthMicrosoftComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i0.ApplicationRef), i0.ɵɵdirectiveInject(i3$2.MsalService), i0.ɵɵdirectiveInject(MSAL_GUARD_CONFIG)); };
543
- AuthMicrosoftComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthMicrosoftComponent, selectors: [["igo-auth-microsoft"]], outputs: { login: "login" }, decls: 4, vars: 3, consts: [["mat-raised-button", "", 1, "microsoft-login-button", 3, "click"], ["svgIcon", "microsoft"]], template: function AuthMicrosoftComponent_Template(rf, ctx) { if (rf & 1) {
544
- i0.ɵɵelementStart(0, "button", 0);
545
- i0.ɵɵlistener("click", function AuthMicrosoftComponent_Template_button_click_0_listener() { return ctx.loginMicrosoft(); });
546
- i0.ɵɵelement(1, "mat-icon", 1);
547
- i0.ɵɵtext(2);
548
- i0.ɵɵpipe(3, "translate");
549
- i0.ɵɵelementEnd();
550
- } if (rf & 2) {
551
- i0.ɵɵadvance(2);
552
- i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(3, 1, "igo.auth.microsoft.login"), "\n");
553
- } }, dependencies: [i4.MatIcon, i5$1.MatButton, i6$1.TranslatePipe], styles: ["[_nghost-%COMP%]{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}[_nghost-%COMP%] > button[_ngcontent-%COMP%]{font-size:15px;height:40px;width:265px}mat-icon[_ngcontent-%COMP%]{margin-right:10px}"], changeDetection: 0 });
554
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthMicrosoftComponent, [{
555
- type: Component,
556
- args: [{ selector: 'igo-auth-microsoft', changeDetection: ChangeDetectionStrategy.OnPush, template: "<button class=\"microsoft-login-button\" mat-raised-button (click)=\"loginMicrosoft()\">\r\n <mat-icon svgIcon=\"microsoft\"></mat-icon>\r\n {{'igo.auth.microsoft.login' | translate}}\r\n</button>\r\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}:host>button{font-size:15px;height:40px;width:265px}mat-icon{margin-right:10px}\n"] }]
557
- }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i0.ApplicationRef }, { type: i3$2.MsalService }, { type: undefined, decorators: [{
558
- type: Inject,
559
- args: [MSAL_GUARD_CONFIG]
560
- }] }]; }, { login: [{
561
- type: Output
514
+ class AuthMicrosoftComponent {
515
+ authService;
516
+ config;
517
+ appRef;
518
+ msalService;
519
+ msalGuardConfig;
520
+ options;
521
+ _destroying$ = new Subject();
522
+ login = new EventEmitter();
523
+ broadcastService;
524
+ constructor(authService, config, appRef, msalService, msalGuardConfig) {
525
+ this.authService = authService;
526
+ this.config = config;
527
+ this.appRef = appRef;
528
+ this.msalService = msalService;
529
+ this.msalGuardConfig = msalGuardConfig;
530
+ this.options = this.config.getConfig('auth.microsoft');
531
+ this.msalService.instance = new PublicClientApplication({
532
+ auth: this.options,
533
+ cache: {
534
+ cacheLocation: 'sessionStorage'
535
+ }
536
+ });
537
+ this.broadcastService = new MsalBroadcastService(this.msalService.instance, this.msalService);
538
+ if (this.options?.clientId) {
539
+ this.broadcastService.inProgress$
540
+ .pipe(filter((status) => status === InteractionStatus.None), takeUntil(this._destroying$))
541
+ .subscribe(() => {
542
+ this.checkAccount();
543
+ });
544
+ }
545
+ else {
546
+ console.warn('Microsoft authentification needs "clientId" option');
547
+ }
548
+ }
549
+ loginMicrosoft() {
550
+ this.msalService
551
+ .loginPopup({ ...this.getConf().authRequest })
552
+ .subscribe((response) => {
553
+ this.msalService.instance.setActiveAccount(response.account);
554
+ this.checkAccount();
555
+ });
556
+ }
557
+ checkAccount() {
558
+ this.msalService.instance
559
+ .acquireTokenSilent(this.getConf().authRequest)
560
+ .then((response) => {
561
+ const tokenAccess = response.accessToken;
562
+ const tokenId = response.idToken;
563
+ this.authService
564
+ .loginWithToken(tokenAccess, 'microsoft', { tokenId })
565
+ .subscribe(() => {
566
+ this.appRef.tick();
567
+ this.login.emit(true);
568
+ });
569
+ })
570
+ .catch(async (error) => {
571
+ if (error instanceof InteractionRequiredAuthError) {
572
+ // fallback to interaction when silent call fails
573
+ return this.msalService.acquireTokenPopup(this.getConf().authRequest);
574
+ }
575
+ console.log(error);
576
+ })
577
+ .catch((error) => {
578
+ console.log('Silent token fails');
579
+ });
580
+ }
581
+ getConf() {
582
+ return this.msalGuardConfig.filter((conf) => conf.type === 'add')[0];
583
+ }
584
+ static ɵfac = function AuthMicrosoftComponent_Factory(t) { return new (t || AuthMicrosoftComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i0.ApplicationRef), i0.ɵɵdirectiveInject(i3$2.MsalService), i0.ɵɵdirectiveInject(MSAL_GUARD_CONFIG)); };
585
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthMicrosoftComponent, selectors: [["igo-auth-microsoft"]], outputs: { login: "login" }, decls: 4, vars: 3, consts: [["mat-raised-button", "", 1, "microsoft-login-button", 3, "click"], ["svgIcon", "microsoft"]], template: function AuthMicrosoftComponent_Template(rf, ctx) { if (rf & 1) {
586
+ i0.ɵɵelementStart(0, "button", 0);
587
+ i0.ɵɵlistener("click", function AuthMicrosoftComponent_Template_button_click_0_listener() { return ctx.loginMicrosoft(); });
588
+ i0.ɵɵelement(1, "mat-icon", 1);
589
+ i0.ɵɵtext(2);
590
+ i0.ɵɵpipe(3, "translate");
591
+ i0.ɵɵelementEnd();
592
+ } if (rf & 2) {
593
+ i0.ɵɵadvance(2);
594
+ i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(3, 1, "igo.auth.microsoft.login"), "\n");
595
+ } }, dependencies: [i4.MatIcon, i5$1.MatButton, i6$1.TranslatePipe], styles: ["[_nghost-%COMP%]{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}[_nghost-%COMP%] > button[_ngcontent-%COMP%]{font-size:15px;height:40px;width:265px}mat-icon[_ngcontent-%COMP%]{margin-right:10px}"], changeDetection: 0 });
596
+ }
597
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthMicrosoftComponent, [{
598
+ type: Component,
599
+ args: [{ selector: 'igo-auth-microsoft', changeDetection: ChangeDetectionStrategy.OnPush, template: "<button\r\n class=\"microsoft-login-button\"\r\n mat-raised-button\r\n (click)=\"loginMicrosoft()\"\r\n>\r\n <mat-icon svgIcon=\"microsoft\"></mat-icon>\r\n {{ 'igo.auth.microsoft.login' | translate }}\r\n</button>\r\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}:host>button{font-size:15px;height:40px;width:265px}mat-icon{margin-right:10px}\n"] }]
600
+ }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i0.ApplicationRef }, { type: i3$2.MsalService }, { type: undefined, decorators: [{
601
+ type: Inject,
602
+ args: [MSAL_GUARD_CONFIG]
603
+ }] }]; }, { login: [{
604
+ type: Output
562
605
  }] }); })();
563
606
 
564
- /*
565
- * Copyright (c) Microsoft Corporation. All rights reserved.
566
- * Licensed under the MIT License.
567
- */
568
- class MsalServiceb2c {
569
- constructor(instance, location) {
570
- this.instance = instance;
571
- this.location = location;
572
- this.name = '@azure/msal-angular';
573
- this.version = '2.0.0-beta.2';
574
- const hash = this.location.path(true).split('#').pop();
575
- if (hash) {
576
- this.redirectHash = `#${hash}`;
577
- }
578
- this.instance.initializeWrapperLibrary(WrapperSKU.Angular, this.version);
579
- }
580
- initialize() {
581
- return from(this.instance.initialize());
582
- }
583
- acquireTokenPopup(request) {
584
- return from(this.instance.acquireTokenPopup(request));
585
- }
586
- acquireTokenRedirect(request) {
587
- return from(this.instance.acquireTokenRedirect(request));
588
- }
589
- acquireTokenSilent(silentRequest) {
590
- return from(this.instance.acquireTokenSilent(silentRequest));
591
- }
592
- handleRedirectObservable(hash) {
593
- return from(this.instance.handleRedirectPromise(hash || this.redirectHash));
594
- }
595
- loginPopup(request) {
596
- return from(this.instance.loginPopup(request));
597
- }
598
- loginRedirect(request) {
599
- return from(this.instance.loginRedirect(request));
600
- }
601
- logout(logoutRequest) {
602
- return from(this.instance.logout(logoutRequest));
603
- }
604
- logoutRedirect(logoutRequest) {
605
- return from(this.instance.logoutRedirect(logoutRequest));
606
- }
607
- logoutPopup(logoutRequest) {
608
- return from(this.instance.logoutPopup(logoutRequest));
609
- }
610
- ssoSilent(request) {
611
- return from(this.instance.ssoSilent(request));
612
- }
613
- /**
614
- * Gets logger for msal-angular.
615
- * If no logger set, returns logger instance created with same options as msal-browser
616
- */
617
- getLogger() {
618
- if (!this.logger) {
619
- this.logger = this.instance.getLogger().clone(this.name, this.version);
620
- }
621
- return this.logger;
622
- }
623
- // Create a logger instance for msal-angular with the same options as msal-browser
624
- setLogger(logger) {
625
- this.logger = logger.clone(this.name, this.version);
626
- this.instance.setLogger(logger);
627
- }
628
- }
629
- MsalServiceb2c.ɵfac = function MsalServiceb2c_Factory(t) { return new (t || MsalServiceb2c)(i0.ɵɵinject(MSAL_INSTANCE), i0.ɵɵinject(i1$1.Location)); };
630
- MsalServiceb2c.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MsalServiceb2c, factory: MsalServiceb2c.ɵfac });
631
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MsalServiceb2c, [{
632
- type: Injectable
633
- }], function () { return [{ type: undefined, decorators: [{
634
- type: Inject,
635
- args: [MSAL_INSTANCE]
607
+ /*
608
+ * Copyright (c) Microsoft Corporation. All rights reserved.
609
+ * Licensed under the MIT License.
610
+ */
611
+ class MsalServiceb2c {
612
+ instance;
613
+ location;
614
+ redirectHash;
615
+ logger;
616
+ name = '@azure/msal-angular';
617
+ version = '2.0.0-beta.2';
618
+ constructor(instance, location) {
619
+ this.instance = instance;
620
+ this.location = location;
621
+ const hash = this.location.path(true).split('#').pop();
622
+ if (hash) {
623
+ this.redirectHash = `#${hash}`;
624
+ }
625
+ this.instance.initializeWrapperLibrary(WrapperSKU.Angular, this.version);
626
+ }
627
+ initialize() {
628
+ return from(this.instance.initialize());
629
+ }
630
+ acquireTokenPopup(request) {
631
+ return from(this.instance.acquireTokenPopup(request));
632
+ }
633
+ acquireTokenRedirect(request) {
634
+ return from(this.instance.acquireTokenRedirect(request));
635
+ }
636
+ acquireTokenSilent(silentRequest) {
637
+ return from(this.instance.acquireTokenSilent(silentRequest));
638
+ }
639
+ handleRedirectObservable(hash) {
640
+ return from(this.instance.handleRedirectPromise(hash || this.redirectHash));
641
+ }
642
+ loginPopup(request) {
643
+ return from(this.instance.loginPopup(request));
644
+ }
645
+ loginRedirect(request) {
646
+ return from(this.instance.loginRedirect(request));
647
+ }
648
+ logout(logoutRequest) {
649
+ return from(this.instance.logout(logoutRequest));
650
+ }
651
+ logoutRedirect(logoutRequest) {
652
+ return from(this.instance.logoutRedirect(logoutRequest));
653
+ }
654
+ logoutPopup(logoutRequest) {
655
+ return from(this.instance.logoutPopup(logoutRequest));
656
+ }
657
+ ssoSilent(request) {
658
+ return from(this.instance.ssoSilent(request));
659
+ }
660
+ /**
661
+ * Gets logger for msal-angular.
662
+ * If no logger set, returns logger instance created with same options as msal-browser
663
+ */
664
+ getLogger() {
665
+ if (!this.logger) {
666
+ this.logger = this.instance.getLogger().clone(this.name, this.version);
667
+ }
668
+ return this.logger;
669
+ }
670
+ // Create a logger instance for msal-angular with the same options as msal-browser
671
+ setLogger(logger) {
672
+ this.logger = logger.clone(this.name, this.version);
673
+ this.instance.setLogger(logger);
674
+ }
675
+ static ɵfac = function MsalServiceb2c_Factory(t) { return new (t || MsalServiceb2c)(i0.ɵɵinject(MSAL_INSTANCE), i0.ɵɵinject(i1$1.Location)); };
676
+ static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MsalServiceb2c, factory: MsalServiceb2c.ɵfac });
677
+ }
678
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MsalServiceb2c, [{
679
+ type: Injectable
680
+ }], function () { return [{ type: undefined, decorators: [{
681
+ type: Inject,
682
+ args: [MSAL_INSTANCE]
636
683
  }] }, { type: i1$1.Location }]; }, null); })();
637
684
 
638
- /*
639
- * Copyright (c) Microsoft Corporation. All rights reserved.
640
- * Licensed under the MIT License.
641
- */
642
- class MsalBroadcastServiceb2c {
643
- constructor(msalInstance, authService) {
644
- this.msalInstance = msalInstance;
645
- this.authService = authService;
646
- this._msalSubject = new Subject();
647
- this.msalSubject$ = this._msalSubject.asObservable();
648
- // InProgress as BehaviorSubject so most recent inProgress state will be available upon subscription
649
- this._inProgress = new BehaviorSubject(InteractionStatus.Startup);
650
- this.inProgress$ = this._inProgress.asObservable();
651
- this.msalInstance.addEventCallback((message) => {
652
- this._msalSubject.next(message);
653
- const status = EventMessageUtils.getInteractionStatusFromEvent(message);
654
- if (status !== null) {
655
- this.authService.getLogger().verbose(`BroadcastService - ${message.eventType} results in setting inProgress to ${status}`);
656
- this._inProgress.next(status);
657
- }
658
- });
659
- }
660
- }
661
- MsalBroadcastServiceb2c.ɵfac = function MsalBroadcastServiceb2c_Factory(t) { return new (t || MsalBroadcastServiceb2c)(i0.ɵɵinject(MSAL_INSTANCE), i0.ɵɵinject(MsalServiceb2c)); };
662
- MsalBroadcastServiceb2c.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MsalBroadcastServiceb2c, factory: MsalBroadcastServiceb2c.ɵfac });
663
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MsalBroadcastServiceb2c, [{
664
- type: Injectable
665
- }], function () { return [{ type: undefined, decorators: [{
666
- type: Inject,
667
- args: [MSAL_INSTANCE]
685
+ /*
686
+ * Copyright (c) Microsoft Corporation. All rights reserved.
687
+ * Licensed under the MIT License.
688
+ */
689
+ class MsalBroadcastServiceb2c {
690
+ msalInstance;
691
+ authService;
692
+ _msalSubject;
693
+ msalSubject$;
694
+ _inProgress;
695
+ inProgress$;
696
+ constructor(msalInstance, authService) {
697
+ this.msalInstance = msalInstance;
698
+ this.authService = authService;
699
+ this._msalSubject = new Subject();
700
+ this.msalSubject$ = this._msalSubject.asObservable();
701
+ // InProgress as BehaviorSubject so most recent inProgress state will be available upon subscription
702
+ this._inProgress = new BehaviorSubject(InteractionStatus.Startup);
703
+ this.inProgress$ = this._inProgress.asObservable();
704
+ this.msalInstance.addEventCallback((message) => {
705
+ this._msalSubject.next(message);
706
+ const status = EventMessageUtils.getInteractionStatusFromEvent(message);
707
+ if (status !== null) {
708
+ this.authService
709
+ .getLogger()
710
+ .verbose(`BroadcastService - ${message.eventType} results in setting inProgress to ${status}`);
711
+ this._inProgress.next(status);
712
+ }
713
+ });
714
+ }
715
+ static ɵfac = function MsalBroadcastServiceb2c_Factory(t) { return new (t || MsalBroadcastServiceb2c)(i0.ɵɵinject(MSAL_INSTANCE), i0.ɵɵinject(MsalServiceb2c)); };
716
+ static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MsalBroadcastServiceb2c, factory: MsalBroadcastServiceb2c.ɵfac });
717
+ }
718
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MsalBroadcastServiceb2c, [{
719
+ type: Injectable
720
+ }], function () { return [{ type: undefined, decorators: [{
721
+ type: Inject,
722
+ args: [MSAL_INSTANCE]
668
723
  }] }, { type: MsalServiceb2c }]; }, null); })();
669
724
 
670
- class AuthMicrosoftb2cComponent {
671
- constructor(authService, config, appRef, msalService, msalGuardConfig) {
672
- this.authService = authService;
673
- this.config = config;
674
- this.appRef = appRef;
675
- this.msalService = msalService;
676
- this.msalGuardConfig = msalGuardConfig;
677
- this._destroying$ = new Subject();
678
- this.login = new EventEmitter();
679
- this.options = this.config.getConfig('auth.microsoftb2c') || {};
680
- this.msalService.instance = new PublicClientApplication({
681
- auth: this.options.browserAuthOptions,
682
- cache: {
683
- cacheLocation: 'sessionStorage'
684
- }
685
- });
686
- this.broadcastService = new MsalBroadcastServiceb2c(this.msalService.instance, this.msalService);
687
- if (this.options.browserAuthOptions.clientId) {
688
- this.broadcastService.inProgress$
689
- .pipe(filter((status) => status === InteractionStatus.None), takeUntil(this._destroying$))
690
- .subscribe(() => {
691
- this.checkAccount();
692
- });
693
- }
694
- else {
695
- console.warn('Microsoft authentification needs "clientId" option');
696
- }
697
- }
698
- loginMicrosoftb2c() {
699
- this.msalService.loginPopup({ ...this.getConf().authRequest })
700
- .subscribe((response) => {
701
- this.msalService.instance.setActiveAccount(response.account);
702
- this.checkAccount();
703
- });
704
- }
705
- checkAccount() {
706
- this.msalService.instance
707
- .acquireTokenSilent(this.getConf().authRequest)
708
- .then((response) => {
709
- const token = response.idToken;
710
- this.authService.loginWithToken(token, 'microsoftb2c').subscribe(() => {
711
- this.appRef.tick();
712
- this.login.emit(true);
713
- });
714
- })
715
- .catch(async (error) => {
716
- if (error instanceof InteractionRequiredAuthError) {
717
- // fallback to interaction when silent call fails
718
- return this.msalService.acquireTokenPopup(this.getConf().authRequest);
719
- }
720
- }).catch(error => {
721
- console.log('Silent token fails');
722
- });
723
- }
724
- getConf() {
725
- return this.msalGuardConfig.filter(conf => conf.type === 'b2c')[0];
726
- }
727
- }
728
- AuthMicrosoftb2cComponent.ɵfac = function AuthMicrosoftb2cComponent_Factory(t) { return new (t || AuthMicrosoftb2cComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i0.ApplicationRef), i0.ɵɵdirectiveInject(MsalServiceb2c), i0.ɵɵdirectiveInject(MSAL_GUARD_CONFIG)); };
729
- AuthMicrosoftb2cComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthMicrosoftb2cComponent, selectors: [["igo-auth-microsoftb2c"]], outputs: { login: "login" }, decls: 4, vars: 3, consts: [["mat-raised-button", "", 1, "microsoft-login-button", 3, "click"], ["svgIcon", "microsoft"]], template: function AuthMicrosoftb2cComponent_Template(rf, ctx) { if (rf & 1) {
730
- i0.ɵɵelementStart(0, "button", 0);
731
- i0.ɵɵlistener("click", function AuthMicrosoftb2cComponent_Template_button_click_0_listener() { return ctx.loginMicrosoftb2c(); });
732
- i0.ɵɵelement(1, "mat-icon", 1);
733
- i0.ɵɵtext(2);
734
- i0.ɵɵpipe(3, "translate");
735
- i0.ɵɵelementEnd();
736
- } if (rf & 2) {
737
- i0.ɵɵadvance(2);
738
- i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(3, 1, "igo.auth.microsoftb2c.login"), "\n");
739
- } }, dependencies: [i4.MatIcon, i5$1.MatButton, i6$1.TranslatePipe], styles: ["[_nghost-%COMP%]{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}[_nghost-%COMP%] > button[_ngcontent-%COMP%]{font-size:15px;height:40px;width:265px}mat-icon[_ngcontent-%COMP%]{margin-right:10px}"], changeDetection: 0 });
740
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthMicrosoftb2cComponent, [{
741
- type: Component,
742
- args: [{ selector: 'igo-auth-microsoftb2c', changeDetection: ChangeDetectionStrategy.OnPush, template: "<button class=\"microsoft-login-button\" mat-raised-button (click)=\"loginMicrosoftb2c()\">\r\n <mat-icon svgIcon=\"microsoft\"></mat-icon>\r\n {{'igo.auth.microsoftb2c.login' | translate}}\r\n</button>\r\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}:host>button{font-size:15px;height:40px;width:265px}mat-icon{margin-right:10px}\n"] }]
743
- }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i0.ApplicationRef }, { type: MsalServiceb2c }, { type: undefined, decorators: [{
744
- type: Inject,
745
- args: [MSAL_GUARD_CONFIG]
746
- }] }]; }, { login: [{
747
- type: Output
725
+ class AuthMicrosoftb2cComponent {
726
+ authService;
727
+ config;
728
+ appRef;
729
+ msalService;
730
+ msalGuardConfig;
731
+ options;
732
+ _destroying$ = new Subject();
733
+ login = new EventEmitter();
734
+ broadcastService;
735
+ constructor(authService, config, appRef, msalService, msalGuardConfig) {
736
+ this.authService = authService;
737
+ this.config = config;
738
+ this.appRef = appRef;
739
+ this.msalService = msalService;
740
+ this.msalGuardConfig = msalGuardConfig;
741
+ this.options = this.config.getConfig('auth.microsoftb2c') || {};
742
+ this.msalService.instance = new PublicClientApplication({
743
+ auth: this.options.browserAuthOptions,
744
+ cache: {
745
+ cacheLocation: 'sessionStorage'
746
+ }
747
+ });
748
+ this.broadcastService = new MsalBroadcastServiceb2c(this.msalService.instance, this.msalService);
749
+ if (this.options.browserAuthOptions.clientId) {
750
+ this.broadcastService.inProgress$
751
+ .pipe(filter((status) => status === InteractionStatus.None), takeUntil(this._destroying$))
752
+ .subscribe(() => {
753
+ this.checkAccount();
754
+ });
755
+ }
756
+ else {
757
+ console.warn('Microsoft authentification needs "clientId" option');
758
+ }
759
+ }
760
+ loginMicrosoftb2c() {
761
+ this.msalService
762
+ .loginPopup({ ...this.getConf().authRequest })
763
+ .subscribe((response) => {
764
+ this.msalService.instance.setActiveAccount(response.account);
765
+ this.checkAccount();
766
+ });
767
+ }
768
+ checkAccount() {
769
+ this.msalService.instance
770
+ .acquireTokenSilent(this.getConf().authRequest)
771
+ .then((response) => {
772
+ const token = response.idToken;
773
+ this.authService.loginWithToken(token, 'microsoftb2c').subscribe(() => {
774
+ this.appRef.tick();
775
+ this.login.emit(true);
776
+ });
777
+ })
778
+ .catch(async (error) => {
779
+ if (error instanceof InteractionRequiredAuthError) {
780
+ // fallback to interaction when silent call fails
781
+ return this.msalService.acquireTokenPopup(this.getConf().authRequest);
782
+ }
783
+ })
784
+ .catch((error) => {
785
+ console.log('Silent token fails');
786
+ });
787
+ }
788
+ getConf() {
789
+ return this.msalGuardConfig.filter((conf) => conf.type === 'b2c')[0];
790
+ }
791
+ static ɵfac = function AuthMicrosoftb2cComponent_Factory(t) { return new (t || AuthMicrosoftb2cComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i0.ApplicationRef), i0.ɵɵdirectiveInject(MsalServiceb2c), i0.ɵɵdirectiveInject(MSAL_GUARD_CONFIG)); };
792
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthMicrosoftb2cComponent, selectors: [["igo-auth-microsoftb2c"]], outputs: { login: "login" }, decls: 4, vars: 3, consts: [["mat-raised-button", "", 1, "microsoft-login-button", 3, "click"], ["svgIcon", "microsoft"]], template: function AuthMicrosoftb2cComponent_Template(rf, ctx) { if (rf & 1) {
793
+ i0.ɵɵelementStart(0, "button", 0);
794
+ i0.ɵɵlistener("click", function AuthMicrosoftb2cComponent_Template_button_click_0_listener() { return ctx.loginMicrosoftb2c(); });
795
+ i0.ɵɵelement(1, "mat-icon", 1);
796
+ i0.ɵɵtext(2);
797
+ i0.ɵɵpipe(3, "translate");
798
+ i0.ɵɵelementEnd();
799
+ } if (rf & 2) {
800
+ i0.ɵɵadvance(2);
801
+ i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(3, 1, "igo.auth.microsoftb2c.login"), "\n");
802
+ } }, dependencies: [i4.MatIcon, i5$1.MatButton, i6$1.TranslatePipe], styles: ["[_nghost-%COMP%]{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}[_nghost-%COMP%] > button[_ngcontent-%COMP%]{font-size:15px;height:40px;width:265px}mat-icon[_ngcontent-%COMP%]{margin-right:10px}"], changeDetection: 0 });
803
+ }
804
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthMicrosoftb2cComponent, [{
805
+ type: Component,
806
+ args: [{ selector: 'igo-auth-microsoftb2c', changeDetection: ChangeDetectionStrategy.OnPush, template: "<button\r\n class=\"microsoft-login-button\"\r\n mat-raised-button\r\n (click)=\"loginMicrosoftb2c()\"\r\n>\r\n <mat-icon svgIcon=\"microsoft\"></mat-icon>\r\n {{ 'igo.auth.microsoftb2c.login' | translate }}\r\n</button>\r\n", styles: [":host{padding:10px 10px 10px 0;display:inline-block;position:relative;top:-15px}:host>button{font-size:15px;height:40px;width:265px}mat-icon{margin-right:10px}\n"] }]
807
+ }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i0.ApplicationRef }, { type: MsalServiceb2c }, { type: undefined, decorators: [{
808
+ type: Inject,
809
+ args: [MSAL_GUARD_CONFIG]
810
+ }] }]; }, { login: [{
811
+ type: Output
748
812
  }] }); })();
749
813
 
750
- function AuthFormComponent_div_0_div_1_Template(rf, ctx) { if (rf & 1) {
751
- i0.ɵɵelement(0, "div", 3);
752
- } }
753
- function AuthFormComponent_div_0_div_2_igo_auth_google_4_Template(rf, ctx) { if (rf & 1) {
754
- const _r11 = i0.ɵɵgetCurrentView();
755
- i0.ɵɵelementStart(0, "igo-auth-google", 7);
756
- i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_google_4_Template_igo_auth_google_login_0_listener() { i0.ɵɵrestoreView(_r11); const ctx_r10 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r10.onLogin()); });
757
- i0.ɵɵelementEnd();
758
- } }
759
- function AuthFormComponent_div_0_div_2_igo_auth_microsoft_5_Template(rf, ctx) { if (rf & 1) {
760
- const _r13 = i0.ɵɵgetCurrentView();
761
- i0.ɵɵelementStart(0, "igo-auth-microsoft", 7);
762
- i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_microsoft_5_Template_igo_auth_microsoft_login_0_listener() { i0.ɵɵrestoreView(_r13); const ctx_r12 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r12.onLogin()); });
763
- i0.ɵɵelementEnd();
764
- } }
765
- function AuthFormComponent_div_0_div_2_igo_auth_microsoftb2c_6_Template(rf, ctx) { if (rf & 1) {
766
- const _r15 = i0.ɵɵgetCurrentView();
767
- i0.ɵɵelementStart(0, "igo-auth-microsoftb2c", 7);
768
- i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_microsoftb2c_6_Template_igo_auth_microsoftb2c_login_0_listener() { i0.ɵɵrestoreView(_r15); const ctx_r14 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r14.onLogin()); });
769
- i0.ɵɵelementEnd();
770
- } }
771
- function AuthFormComponent_div_0_div_2_igo_auth_facebook_7_Template(rf, ctx) { if (rf & 1) {
772
- const _r17 = i0.ɵɵgetCurrentView();
773
- i0.ɵɵelementStart(0, "igo-auth-facebook", 7);
774
- i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_facebook_7_Template_igo_auth_facebook_login_0_listener() { i0.ɵɵrestoreView(_r17); const ctx_r16 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r16.onLogin()); });
775
- i0.ɵɵelementEnd();
776
- } }
777
- function AuthFormComponent_div_0_div_2_igo_auth_intern_8_Template(rf, ctx) { if (rf & 1) {
778
- const _r19 = i0.ɵɵgetCurrentView();
779
- i0.ɵɵelementStart(0, "igo-auth-intern", 8);
780
- i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_intern_8_Template_igo_auth_intern_login_0_listener() { i0.ɵɵrestoreView(_r19); const ctx_r18 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r18.onLogin()); });
781
- i0.ɵɵelementEnd();
782
- } if (rf & 2) {
783
- const ctx_r9 = i0.ɵɵnextContext(3);
784
- i0.ɵɵproperty("allowAnonymous", ctx_r9.options.allowAnonymous);
785
- } }
786
- function AuthFormComponent_div_0_div_2_Template(rf, ctx) { if (rf & 1) {
787
- i0.ɵɵelementStart(0, "div", 4)(1, "h1");
788
- i0.ɵɵtext(2);
789
- i0.ɵɵpipe(3, "translate");
790
- i0.ɵɵelementEnd();
791
- i0.ɵɵtemplate(4, AuthFormComponent_div_0_div_2_igo_auth_google_4_Template, 1, 0, "igo-auth-google", 5);
792
- i0.ɵɵtemplate(5, AuthFormComponent_div_0_div_2_igo_auth_microsoft_5_Template, 1, 0, "igo-auth-microsoft", 5);
793
- i0.ɵɵtemplate(6, AuthFormComponent_div_0_div_2_igo_auth_microsoftb2c_6_Template, 1, 0, "igo-auth-microsoftb2c", 5);
794
- i0.ɵɵtemplate(7, AuthFormComponent_div_0_div_2_igo_auth_facebook_7_Template, 1, 0, "igo-auth-facebook", 5);
795
- i0.ɵɵtemplate(8, AuthFormComponent_div_0_div_2_igo_auth_intern_8_Template, 1, 1, "igo-auth-intern", 6);
796
- i0.ɵɵelementEnd();
797
- } if (rf & 2) {
798
- const ctx_r2 = i0.ɵɵnextContext(2);
799
- i0.ɵɵadvance(2);
800
- i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(3, 6, "igo.auth.connection"));
801
- i0.ɵɵadvance(2);
802
- i0.ɵɵproperty("ngIf", ctx_r2.options.google && ctx_r2.options.google.enabled !== false);
803
- i0.ɵɵadvance(1);
804
- i0.ɵɵproperty("ngIf", ctx_r2.options.microsoft && ctx_r2.options.microsoft.enabled !== false);
805
- i0.ɵɵadvance(1);
806
- i0.ɵɵproperty("ngIf", ctx_r2.options.microsoftb2c && ctx_r2.options.microsoftb2c.enabled !== false);
807
- i0.ɵɵadvance(1);
808
- i0.ɵɵproperty("ngIf", ctx_r2.options.facebook && ctx_r2.options.facebook.enabled !== false);
809
- i0.ɵɵadvance(1);
810
- i0.ɵɵproperty("ngIf", !ctx_r2.options.intern || ctx_r2.options.intern.enabled !== false);
811
- } }
812
- function AuthFormComponent_div_0_div_3_Template(rf, ctx) { if (rf & 1) {
813
- const _r21 = i0.ɵɵgetCurrentView();
814
- i0.ɵɵelementStart(0, "div", 4)(1, "p");
815
- i0.ɵɵtext(2);
816
- i0.ɵɵpipe(3, "translate");
817
- i0.ɵɵelementEnd();
818
- i0.ɵɵelementStart(4, "button", 9);
819
- i0.ɵɵlistener("click", function AuthFormComponent_div_0_div_3_Template_button_click_4_listener() { i0.ɵɵrestoreView(_r21); const ctx_r20 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r20.logout()); });
820
- i0.ɵɵtext(5);
821
- i0.ɵɵpipe(6, "translate");
822
- i0.ɵɵelementEnd()();
823
- } if (rf & 2) {
824
- const ctx_r3 = i0.ɵɵnextContext(2);
825
- i0.ɵɵadvance(2);
826
- i0.ɵɵtextInterpolate(i0.ɵɵpipeBind2(3, 2, "igo.auth.welcome", ctx_r3.user));
827
- i0.ɵɵadvance(3);
828
- i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(6, 5, "igo.auth.signOut"));
829
- } }
830
- function AuthFormComponent_div_0_div_4_button_4_Template(rf, ctx) { if (rf & 1) {
831
- const _r24 = i0.ɵɵgetCurrentView();
832
- i0.ɵɵelementStart(0, "button", 9);
833
- i0.ɵɵlistener("click", function AuthFormComponent_div_0_div_4_button_4_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r24); const ctx_r23 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r23.home()); });
834
- i0.ɵɵtext(1);
835
- i0.ɵɵpipe(2, "translate");
836
- i0.ɵɵelementEnd();
837
- } if (rf & 2) {
838
- i0.ɵɵadvance(1);
839
- i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(2, 1, "igo.auth.home"));
840
- } }
841
- function AuthFormComponent_div_0_div_4_Template(rf, ctx) { if (rf & 1) {
842
- i0.ɵɵelementStart(0, "div", 4)(1, "p");
843
- i0.ɵɵtext(2);
844
- i0.ɵɵpipe(3, "translate");
845
- i0.ɵɵelementEnd();
846
- i0.ɵɵtemplate(4, AuthFormComponent_div_0_div_4_button_4_Template, 3, 3, "button", 10);
847
- i0.ɵɵelementEnd();
848
- } if (rf & 2) {
849
- const ctx_r4 = i0.ɵɵnextContext(2);
850
- i0.ɵɵadvance(2);
851
- i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(3, 2, "igo.auth.deconnection"));
852
- i0.ɵɵadvance(2);
853
- i0.ɵɵproperty("ngIf", ctx_r4.options.homeRoute);
854
- } }
855
- function AuthFormComponent_div_0_Template(rf, ctx) { if (rf & 1) {
856
- i0.ɵɵelementStart(0, "div");
857
- i0.ɵɵtemplate(1, AuthFormComponent_div_0_div_1_Template, 1, 0, "div", 1);
858
- i0.ɵɵtemplate(2, AuthFormComponent_div_0_div_2_Template, 9, 8, "div", 2);
859
- i0.ɵɵtemplate(3, AuthFormComponent_div_0_div_3_Template, 7, 7, "div", 2);
860
- i0.ɵɵtemplate(4, AuthFormComponent_div_0_div_4_Template, 5, 4, "div", 2);
861
- i0.ɵɵelementEnd();
862
- } if (rf & 2) {
863
- const ctx_r0 = i0.ɵɵnextContext();
864
- i0.ɵɵadvance(1);
865
- i0.ɵɵproperty("ngIf", !ctx_r0.auth.logged && ctx_r0.backgroundDisable);
866
- i0.ɵɵadvance(1);
867
- i0.ɵɵproperty("ngIf", !ctx_r0.auth.logged && ctx_r0.showLoginDiv);
868
- i0.ɵɵadvance(1);
869
- i0.ɵɵproperty("ngIf", ctx_r0.auth.logged && ctx_r0.showAlreadyConnectedDiv);
870
- i0.ɵɵadvance(1);
871
- i0.ɵɵproperty("ngIf", ctx_r0.showLogoutDiv);
872
- } }
873
- class AuthFormComponent {
874
- constructor(auth, config, router) {
875
- this.auth = auth;
876
- this.config = config;
877
- this.router = router;
878
- this._backgroundDisable = true;
879
- this._hasAlreadyConnectedDiv = true;
880
- this._hasLogoutDiv = true;
881
- this._showAlreadyConnectedDiv = false;
882
- this._showLogoutDiv = false;
883
- this.login = new EventEmitter();
884
- this.visible = true;
885
- this.options = this.config.getConfig('auth') || {};
886
- this.visible = Object.getOwnPropertyNames(this.options).length !== 0;
887
- }
888
- get backgroundDisable() {
889
- if (this.isLogoutRoute || this.isLogoutRoute) {
890
- return false;
891
- }
892
- return this._backgroundDisable;
893
- }
894
- set backgroundDisable(value) {
895
- this._backgroundDisable = value.toString() === 'true';
896
- }
897
- get hasAlreadyConnectedDiv() {
898
- return this._hasAlreadyConnectedDiv;
899
- }
900
- set hasAlreadyConnectedDiv(value) {
901
- this._hasAlreadyConnectedDiv = value.toString() === 'true';
902
- }
903
- get hasLogoutDiv() {
904
- return this._hasLogoutDiv;
905
- }
906
- set hasLogoutDiv(value) {
907
- this._hasLogoutDiv = value.toString() === 'true';
908
- }
909
- get showAlreadyConnectedDiv() {
910
- if (this.isLogoutRoute) {
911
- return this.hasAlreadyConnectedDiv;
912
- }
913
- return this._showAlreadyConnectedDiv;
914
- }
915
- set showAlreadyConnectedDiv(value) {
916
- this._showAlreadyConnectedDiv = value.toString() === 'true';
917
- }
918
- get showLogoutDiv() {
919
- if (this.isLogoutRoute) {
920
- return this.hasLogoutDiv;
921
- }
922
- return this._showLogoutDiv;
923
- }
924
- set showLogoutDiv(value) {
925
- this._showLogoutDiv = value.toString() === 'true';
926
- }
927
- get showLoginDiv() {
928
- if (!this.isLogoutRoute) {
929
- return true;
930
- }
931
- }
932
- ngOnInit() {
933
- this.analyzeRoute();
934
- this.getName();
935
- }
936
- onLogin() {
937
- this.auth.goToRedirectUrl();
938
- this.getName();
939
- this.login.emit(true);
940
- }
941
- logout() {
942
- this.auth.logout().subscribe(() => {
943
- this.user = undefined;
944
- if (this.router) {
945
- if (this.options.logoutRoute) {
946
- this.router.navigate([this.options.logoutRoute]);
947
- }
948
- else if (this.options.homeRoute) {
949
- this.router.navigate([this.options.homeRoute]);
950
- }
951
- }
952
- });
953
- }
954
- home() {
955
- if (this.router && this.options.homeRoute) {
956
- this.router.navigate([this.options.homeRoute]);
957
- }
958
- }
959
- getName() {
960
- const tokenDecoded = this.auth.decodeToken();
961
- if (tokenDecoded) {
962
- this.user = {
963
- name: tokenDecoded.user.firstName || tokenDecoded.user.sourceId
964
- };
965
- }
966
- }
967
- analyzeRoute() {
968
- if (!this.router) {
969
- return;
970
- }
971
- this.router.events
972
- .pipe(filter((event) => event instanceof NavigationStart))
973
- .subscribe((changeEvent) => {
974
- if (changeEvent.url) {
975
- const currentRoute = changeEvent.url;
976
- const logoutRoute = this.options.logoutRoute;
977
- const loginRoute = this.options.loginRoute;
978
- this.isLogoutRoute = currentRoute === logoutRoute;
979
- this.isLoginRoute = currentRoute === loginRoute;
980
- if (this.isLogoutRoute) {
981
- this.auth.logout();
982
- }
983
- }
984
- });
985
- }
986
- }
987
- AuthFormComponent.ɵfac = function AuthFormComponent_Factory(t) { return new (t || AuthFormComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i3.Router, 8)); };
988
- AuthFormComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthFormComponent, selectors: [["igo-auth-form"]], inputs: { backgroundDisable: "backgroundDisable", hasAlreadyConnectedDiv: "hasAlreadyConnectedDiv", hasLogoutDiv: "hasLogoutDiv", showAlreadyConnectedDiv: "showAlreadyConnectedDiv", showLogoutDiv: "showLogoutDiv" }, outputs: { login: "login" }, decls: 1, vars: 1, consts: [[4, "ngIf"], ["class", "backgroundDisable", 4, "ngIf"], ["class", "login center-block", 4, "ngIf"], [1, "backgroundDisable"], [1, "login", "center-block"], [3, "login", 4, "ngIf"], [3, "allowAnonymous", "login", 4, "ngIf"], [3, "login"], [3, "allowAnonymous", "login"], ["mat-raised-button", "", "type", "button", 3, "click"], ["mat-raised-button", "", "type", "button", 3, "click", 4, "ngIf"]], template: function AuthFormComponent_Template(rf, ctx) { if (rf & 1) {
989
- i0.ɵɵtemplate(0, AuthFormComponent_div_0_Template, 5, 4, "div", 0);
990
- } if (rf & 2) {
991
- i0.ɵɵproperty("ngIf", ctx.visible);
992
- } }, dependencies: [i1$1.NgIf, i5$1.MatButton, AuthGoogleComponent, AuthInternComponent, AuthFacebookComponent, AuthMicrosoftComponent, AuthMicrosoftb2cComponent, i6$1.TranslatePipe], styles: ["[_nghost-%COMP%]{z-index:999}div.login[_ngcontent-%COMP%]{z-index:200;width:90%;min-width:360px;max-width:600px;padding:25px 50px;border:1px solid;background-color:#fff;border-color:#888}.center-block[_ngcontent-%COMP%]{position:fixed;top:20%;left:50%;transform:translate(-50%)}.backgroundDisable[_ngcontent-%COMP%]{position:fixed;top:0;left:0;background:#000;opacity:.8;z-index:100;height:100%;width:100%}"] });
993
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthFormComponent, [{
994
- type: Component,
995
- args: [{ selector: 'igo-auth-form', changeDetection: ChangeDetectionStrategy.Default, template: "<div *ngIf=\"visible\">\r\n <div *ngIf=\"!auth.logged && backgroundDisable\" class=\"backgroundDisable\"></div>\r\n\r\n <div *ngIf=\"!auth.logged && showLoginDiv\" class=\"login center-block\">\r\n <h1>{{'igo.auth.connection' | translate}}</h1>\r\n\r\n <igo-auth-google\r\n *ngIf=\"options.google && options.google.enabled !== false\"\r\n (login)=\"onLogin()\">\r\n </igo-auth-google>\r\n <igo-auth-microsoft\r\n *ngIf=\"options.microsoft && options.microsoft.enabled !== false\"\r\n (login)=\"onLogin()\">\r\n </igo-auth-microsoft>\r\n <igo-auth-microsoftb2c\r\n *ngIf=\"options.microsoftb2c && options.microsoftb2c.enabled !== false\"\r\n (login)=\"onLogin()\">\r\n </igo-auth-microsoftb2c>\r\n <igo-auth-facebook\r\n *ngIf=\"options.facebook && options.facebook.enabled !== false\"\r\n (login)=\"onLogin()\">\r\n </igo-auth-facebook>\r\n <igo-auth-intern\r\n *ngIf=\"!options.intern || options.intern.enabled !== false\"\r\n [allowAnonymous]=\"options.allowAnonymous\"\r\n (login)=\"onLogin()\">\r\n </igo-auth-intern>\r\n </div>\r\n\r\n <div *ngIf=\"auth.logged && showAlreadyConnectedDiv\" class=\"login center-block\">\r\n <p>{{'igo.auth.welcome' |\u00A0translate: user}}</p>\r\n <button mat-raised-button type=\"button\" (click)=\"logout()\">{{'igo.auth.signOut' |\u00A0translate}}</button>\r\n </div>\r\n\r\n <div *ngIf=\"showLogoutDiv\" class=\"login center-block\">\r\n <p>{{'igo.auth.deconnection' |\u00A0translate}}</p>\r\n <button *ngIf=\"options.homeRoute\" mat-raised-button type=\"button\" (click)=\"home()\">{{'igo.auth.home' |\u00A0translate}}</button>\r\n </div>\r\n\r\n</div>\r\n", styles: [":host{z-index:999}div.login{z-index:200;width:90%;min-width:360px;max-width:600px;padding:25px 50px;border:1px solid;background-color:#fff;border-color:#888}.center-block{position:fixed;top:20%;left:50%;transform:translate(-50%)}.backgroundDisable{position:fixed;top:0;left:0;background:#000;opacity:.8;z-index:100;height:100%;width:100%}\n"] }]
996
- }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router, decorators: [{
997
- type: Optional
998
- }] }]; }, { backgroundDisable: [{
999
- type: Input
1000
- }], hasAlreadyConnectedDiv: [{
1001
- type: Input
1002
- }], hasLogoutDiv: [{
1003
- type: Input
1004
- }], showAlreadyConnectedDiv: [{
1005
- type: Input
1006
- }], showLogoutDiv: [{
1007
- type: Input
1008
- }], login: [{
1009
- type: Output
814
+ function AuthFormComponent_div_0_div_1_Template(rf, ctx) { if (rf & 1) {
815
+ i0.ɵɵelement(0, "div", 3);
816
+ } }
817
+ function AuthFormComponent_div_0_div_2_igo_auth_google_4_Template(rf, ctx) { if (rf & 1) {
818
+ const _r11 = i0.ɵɵgetCurrentView();
819
+ i0.ɵɵelementStart(0, "igo-auth-google", 7);
820
+ i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_google_4_Template_igo_auth_google_login_0_listener() { i0.ɵɵrestoreView(_r11); const ctx_r10 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r10.onLogin()); });
821
+ i0.ɵɵelementEnd();
822
+ } }
823
+ function AuthFormComponent_div_0_div_2_igo_auth_microsoft_5_Template(rf, ctx) { if (rf & 1) {
824
+ const _r13 = i0.ɵɵgetCurrentView();
825
+ i0.ɵɵelementStart(0, "igo-auth-microsoft", 7);
826
+ i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_microsoft_5_Template_igo_auth_microsoft_login_0_listener() { i0.ɵɵrestoreView(_r13); const ctx_r12 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r12.onLogin()); });
827
+ i0.ɵɵelementEnd();
828
+ } }
829
+ function AuthFormComponent_div_0_div_2_igo_auth_microsoftb2c_6_Template(rf, ctx) { if (rf & 1) {
830
+ const _r15 = i0.ɵɵgetCurrentView();
831
+ i0.ɵɵelementStart(0, "igo-auth-microsoftb2c", 7);
832
+ i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_microsoftb2c_6_Template_igo_auth_microsoftb2c_login_0_listener() { i0.ɵɵrestoreView(_r15); const ctx_r14 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r14.onLogin()); });
833
+ i0.ɵɵelementEnd();
834
+ } }
835
+ function AuthFormComponent_div_0_div_2_igo_auth_facebook_7_Template(rf, ctx) { if (rf & 1) {
836
+ const _r17 = i0.ɵɵgetCurrentView();
837
+ i0.ɵɵelementStart(0, "igo-auth-facebook", 7);
838
+ i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_facebook_7_Template_igo_auth_facebook_login_0_listener() { i0.ɵɵrestoreView(_r17); const ctx_r16 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r16.onLogin()); });
839
+ i0.ɵɵelementEnd();
840
+ } }
841
+ function AuthFormComponent_div_0_div_2_igo_auth_intern_8_Template(rf, ctx) { if (rf & 1) {
842
+ const _r19 = i0.ɵɵgetCurrentView();
843
+ i0.ɵɵelementStart(0, "igo-auth-intern", 8);
844
+ i0.ɵɵlistener("login", function AuthFormComponent_div_0_div_2_igo_auth_intern_8_Template_igo_auth_intern_login_0_listener() { i0.ɵɵrestoreView(_r19); const ctx_r18 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r18.onLogin()); });
845
+ i0.ɵɵelementEnd();
846
+ } if (rf & 2) {
847
+ const ctx_r9 = i0.ɵɵnextContext(3);
848
+ i0.ɵɵproperty("allowAnonymous", ctx_r9.options.allowAnonymous);
849
+ } }
850
+ function AuthFormComponent_div_0_div_2_Template(rf, ctx) { if (rf & 1) {
851
+ i0.ɵɵelementStart(0, "div", 4)(1, "h1");
852
+ i0.ɵɵtext(2);
853
+ i0.ɵɵpipe(3, "translate");
854
+ i0.ɵɵelementEnd();
855
+ i0.ɵɵtemplate(4, AuthFormComponent_div_0_div_2_igo_auth_google_4_Template, 1, 0, "igo-auth-google", 5);
856
+ i0.ɵɵtemplate(5, AuthFormComponent_div_0_div_2_igo_auth_microsoft_5_Template, 1, 0, "igo-auth-microsoft", 5);
857
+ i0.ɵɵtemplate(6, AuthFormComponent_div_0_div_2_igo_auth_microsoftb2c_6_Template, 1, 0, "igo-auth-microsoftb2c", 5);
858
+ i0.ɵɵtemplate(7, AuthFormComponent_div_0_div_2_igo_auth_facebook_7_Template, 1, 0, "igo-auth-facebook", 5);
859
+ i0.ɵɵtemplate(8, AuthFormComponent_div_0_div_2_igo_auth_intern_8_Template, 1, 1, "igo-auth-intern", 6);
860
+ i0.ɵɵelementEnd();
861
+ } if (rf & 2) {
862
+ const ctx_r2 = i0.ɵɵnextContext(2);
863
+ i0.ɵɵadvance(2);
864
+ i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(3, 6, "igo.auth.connection"));
865
+ i0.ɵɵadvance(2);
866
+ i0.ɵɵproperty("ngIf", ctx_r2.options.google && ctx_r2.options.google.enabled !== false);
867
+ i0.ɵɵadvance(1);
868
+ i0.ɵɵproperty("ngIf", ctx_r2.options.microsoft && ctx_r2.options.microsoft.enabled !== false);
869
+ i0.ɵɵadvance(1);
870
+ i0.ɵɵproperty("ngIf", ctx_r2.options.microsoftb2c && ctx_r2.options.microsoftb2c.enabled !== false);
871
+ i0.ɵɵadvance(1);
872
+ i0.ɵɵproperty("ngIf", ctx_r2.options.facebook && ctx_r2.options.facebook.enabled !== false);
873
+ i0.ɵɵadvance(1);
874
+ i0.ɵɵproperty("ngIf", !ctx_r2.options.intern || ctx_r2.options.intern.enabled !== false);
875
+ } }
876
+ function AuthFormComponent_div_0_div_3_Template(rf, ctx) { if (rf & 1) {
877
+ const _r21 = i0.ɵɵgetCurrentView();
878
+ i0.ɵɵelementStart(0, "div", 4)(1, "p");
879
+ i0.ɵɵtext(2);
880
+ i0.ɵɵpipe(3, "translate");
881
+ i0.ɵɵelementEnd();
882
+ i0.ɵɵelementStart(4, "button", 9);
883
+ i0.ɵɵlistener("click", function AuthFormComponent_div_0_div_3_Template_button_click_4_listener() { i0.ɵɵrestoreView(_r21); const ctx_r20 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r20.logout()); });
884
+ i0.ɵɵtext(5);
885
+ i0.ɵɵpipe(6, "translate");
886
+ i0.ɵɵelementEnd()();
887
+ } if (rf & 2) {
888
+ const ctx_r3 = i0.ɵɵnextContext(2);
889
+ i0.ɵɵadvance(2);
890
+ i0.ɵɵtextInterpolate(i0.ɵɵpipeBind2(3, 2, "igo.auth.welcome", ctx_r3.user));
891
+ i0.ɵɵadvance(3);
892
+ i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(6, 5, "igo.auth.signOut"), " ");
893
+ } }
894
+ function AuthFormComponent_div_0_div_4_button_4_Template(rf, ctx) { if (rf & 1) {
895
+ const _r24 = i0.ɵɵgetCurrentView();
896
+ i0.ɵɵelementStart(0, "button", 9);
897
+ i0.ɵɵlistener("click", function AuthFormComponent_div_0_div_4_button_4_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r24); const ctx_r23 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r23.home()); });
898
+ i0.ɵɵtext(1);
899
+ i0.ɵɵpipe(2, "translate");
900
+ i0.ɵɵelementEnd();
901
+ } if (rf & 2) {
902
+ i0.ɵɵadvance(1);
903
+ i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 1, "igo.auth.home"), " ");
904
+ } }
905
+ function AuthFormComponent_div_0_div_4_Template(rf, ctx) { if (rf & 1) {
906
+ i0.ɵɵelementStart(0, "div", 4)(1, "p");
907
+ i0.ɵɵtext(2);
908
+ i0.ɵɵpipe(3, "translate");
909
+ i0.ɵɵelementEnd();
910
+ i0.ɵɵtemplate(4, AuthFormComponent_div_0_div_4_button_4_Template, 3, 3, "button", 10);
911
+ i0.ɵɵelementEnd();
912
+ } if (rf & 2) {
913
+ const ctx_r4 = i0.ɵɵnextContext(2);
914
+ i0.ɵɵadvance(2);
915
+ i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(3, 2, "igo.auth.deconnection"));
916
+ i0.ɵɵadvance(2);
917
+ i0.ɵɵproperty("ngIf", ctx_r4.options.homeRoute);
918
+ } }
919
+ function AuthFormComponent_div_0_Template(rf, ctx) { if (rf & 1) {
920
+ i0.ɵɵelementStart(0, "div");
921
+ i0.ɵɵtemplate(1, AuthFormComponent_div_0_div_1_Template, 1, 0, "div", 1);
922
+ i0.ɵɵtemplate(2, AuthFormComponent_div_0_div_2_Template, 9, 8, "div", 2);
923
+ i0.ɵɵtemplate(3, AuthFormComponent_div_0_div_3_Template, 7, 7, "div", 2);
924
+ i0.ɵɵtemplate(4, AuthFormComponent_div_0_div_4_Template, 5, 4, "div", 2);
925
+ i0.ɵɵelementEnd();
926
+ } if (rf & 2) {
927
+ const ctx_r0 = i0.ɵɵnextContext();
928
+ i0.ɵɵadvance(1);
929
+ i0.ɵɵproperty("ngIf", !ctx_r0.auth.logged && ctx_r0.backgroundDisable);
930
+ i0.ɵɵadvance(1);
931
+ i0.ɵɵproperty("ngIf", !ctx_r0.auth.logged && ctx_r0.showLoginDiv);
932
+ i0.ɵɵadvance(1);
933
+ i0.ɵɵproperty("ngIf", ctx_r0.auth.logged && ctx_r0.showAlreadyConnectedDiv);
934
+ i0.ɵɵadvance(1);
935
+ i0.ɵɵproperty("ngIf", ctx_r0.showLogoutDiv);
936
+ } }
937
+ class AuthFormComponent {
938
+ auth;
939
+ config;
940
+ router;
941
+ get backgroundDisable() {
942
+ if (this.isLogoutRoute || this.isLogoutRoute) {
943
+ return false;
944
+ }
945
+ return this._backgroundDisable;
946
+ }
947
+ set backgroundDisable(value) {
948
+ this._backgroundDisable = value.toString() === 'true';
949
+ }
950
+ _backgroundDisable = true;
951
+ get hasAlreadyConnectedDiv() {
952
+ return this._hasAlreadyConnectedDiv;
953
+ }
954
+ set hasAlreadyConnectedDiv(value) {
955
+ this._hasAlreadyConnectedDiv = value.toString() === 'true';
956
+ }
957
+ _hasAlreadyConnectedDiv = true;
958
+ get hasLogoutDiv() {
959
+ return this._hasLogoutDiv;
960
+ }
961
+ set hasLogoutDiv(value) {
962
+ this._hasLogoutDiv = value.toString() === 'true';
963
+ }
964
+ _hasLogoutDiv = true;
965
+ get showAlreadyConnectedDiv() {
966
+ if (this.isLogoutRoute) {
967
+ return this.hasAlreadyConnectedDiv;
968
+ }
969
+ return this._showAlreadyConnectedDiv;
970
+ }
971
+ set showAlreadyConnectedDiv(value) {
972
+ this._showAlreadyConnectedDiv = value.toString() === 'true';
973
+ }
974
+ _showAlreadyConnectedDiv = false;
975
+ get showLogoutDiv() {
976
+ if (this.isLogoutRoute) {
977
+ return this.hasLogoutDiv;
978
+ }
979
+ return this._showLogoutDiv;
980
+ }
981
+ set showLogoutDiv(value) {
982
+ this._showLogoutDiv = value.toString() === 'true';
983
+ }
984
+ _showLogoutDiv = false;
985
+ get showLoginDiv() {
986
+ if (!this.isLogoutRoute) {
987
+ return true;
988
+ }
989
+ }
990
+ login = new EventEmitter();
991
+ options;
992
+ user;
993
+ visible = true;
994
+ isLoginRoute;
995
+ isLogoutRoute;
996
+ constructor(auth, config, router) {
997
+ this.auth = auth;
998
+ this.config = config;
999
+ this.router = router;
1000
+ this.options = this.config.getConfig('auth');
1001
+ this.visible = Object.getOwnPropertyNames(this.options).length !== 0;
1002
+ }
1003
+ ngOnInit() {
1004
+ this.analyzeRoute();
1005
+ this.getName();
1006
+ }
1007
+ onLogin() {
1008
+ this.auth.goToRedirectUrl();
1009
+ this.getName();
1010
+ this.login.emit(true);
1011
+ }
1012
+ logout() {
1013
+ this.auth.logout().subscribe(() => {
1014
+ this.user = undefined;
1015
+ if (this.router) {
1016
+ if (this.options?.logoutRoute) {
1017
+ this.router.navigate([this.options?.logoutRoute]);
1018
+ }
1019
+ else if (this.options?.homeRoute) {
1020
+ this.router.navigate([this.options?.homeRoute]);
1021
+ }
1022
+ }
1023
+ });
1024
+ }
1025
+ home() {
1026
+ if (this.router && this.options?.homeRoute) {
1027
+ this.router.navigate([this.options?.homeRoute]);
1028
+ }
1029
+ }
1030
+ getName() {
1031
+ const tokenDecoded = this.auth.decodeToken();
1032
+ if (tokenDecoded) {
1033
+ this.user = {
1034
+ name: tokenDecoded.user.firstName || tokenDecoded.user.sourceId
1035
+ };
1036
+ }
1037
+ }
1038
+ analyzeRoute() {
1039
+ if (!this.router) {
1040
+ return;
1041
+ }
1042
+ this.router.events
1043
+ .pipe(filter((event) => event instanceof NavigationStart))
1044
+ .subscribe((changeEvent) => {
1045
+ if (changeEvent.url) {
1046
+ const currentRoute = changeEvent.url;
1047
+ const logoutRoute = this.options?.logoutRoute;
1048
+ const loginRoute = this.options?.loginRoute;
1049
+ this.isLogoutRoute = currentRoute === logoutRoute;
1050
+ this.isLoginRoute = currentRoute === loginRoute;
1051
+ if (this.isLogoutRoute) {
1052
+ this.auth.logout();
1053
+ }
1054
+ }
1055
+ });
1056
+ }
1057
+ static ɵfac = function AuthFormComponent_Factory(t) { return new (t || AuthFormComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i2.ConfigService), i0.ɵɵdirectiveInject(i3.Router, 8)); };
1058
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthFormComponent, selectors: [["igo-auth-form"]], inputs: { backgroundDisable: "backgroundDisable", hasAlreadyConnectedDiv: "hasAlreadyConnectedDiv", hasLogoutDiv: "hasLogoutDiv", showAlreadyConnectedDiv: "showAlreadyConnectedDiv", showLogoutDiv: "showLogoutDiv" }, outputs: { login: "login" }, decls: 1, vars: 1, consts: [[4, "ngIf"], ["class", "backgroundDisable", 4, "ngIf"], ["class", "login center-block", 4, "ngIf"], [1, "backgroundDisable"], [1, "login", "center-block"], [3, "login", 4, "ngIf"], [3, "allowAnonymous", "login", 4, "ngIf"], [3, "login"], [3, "allowAnonymous", "login"], ["mat-raised-button", "", "type", "button", 3, "click"], ["mat-raised-button", "", "type", "button", 3, "click", 4, "ngIf"]], template: function AuthFormComponent_Template(rf, ctx) { if (rf & 1) {
1059
+ i0.ɵɵtemplate(0, AuthFormComponent_div_0_Template, 5, 4, "div", 0);
1060
+ } if (rf & 2) {
1061
+ i0.ɵɵproperty("ngIf", ctx.visible);
1062
+ } }, dependencies: [i1$1.NgIf, i5$1.MatButton, AuthGoogleComponent, AuthInternComponent, AuthFacebookComponent, AuthMicrosoftComponent, AuthMicrosoftb2cComponent, i6$1.TranslatePipe], styles: ["[_nghost-%COMP%]{z-index:999}div.login[_ngcontent-%COMP%]{z-index:200;width:90%;min-width:360px;max-width:600px;padding:25px 50px;border:1px solid;background-color:#fff;border-color:#888}.center-block[_ngcontent-%COMP%]{position:fixed;top:20%;left:50%;transform:translate(-50%)}.backgroundDisable[_ngcontent-%COMP%]{position:fixed;top:0;left:0;background:#000;opacity:.8;z-index:100;height:100%;width:100%}"] });
1063
+ }
1064
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthFormComponent, [{
1065
+ type: Component,
1066
+ args: [{ selector: 'igo-auth-form', changeDetection: ChangeDetectionStrategy.Default, template: "<div *ngIf=\"visible\">\r\n <div\r\n *ngIf=\"!auth.logged && backgroundDisable\"\r\n class=\"backgroundDisable\"\r\n ></div>\r\n\r\n <div *ngIf=\"!auth.logged && showLoginDiv\" class=\"login center-block\">\r\n <h1>{{ 'igo.auth.connection' | translate }}</h1>\r\n\r\n <igo-auth-google\r\n *ngIf=\"options.google && options.google.enabled !== false\"\r\n (login)=\"onLogin()\"\r\n >\r\n </igo-auth-google>\r\n <igo-auth-microsoft\r\n *ngIf=\"options.microsoft && options.microsoft.enabled !== false\"\r\n (login)=\"onLogin()\"\r\n >\r\n </igo-auth-microsoft>\r\n <igo-auth-microsoftb2c\r\n *ngIf=\"options.microsoftb2c && options.microsoftb2c.enabled !== false\"\r\n (login)=\"onLogin()\"\r\n >\r\n </igo-auth-microsoftb2c>\r\n <igo-auth-facebook\r\n *ngIf=\"options.facebook && options.facebook.enabled !== false\"\r\n (login)=\"onLogin()\"\r\n >\r\n </igo-auth-facebook>\r\n <igo-auth-intern\r\n *ngIf=\"!options.intern || options.intern.enabled !== false\"\r\n [allowAnonymous]=\"options.allowAnonymous\"\r\n (login)=\"onLogin()\"\r\n >\r\n </igo-auth-intern>\r\n </div>\r\n\r\n <div\r\n *ngIf=\"auth.logged && showAlreadyConnectedDiv\"\r\n class=\"login center-block\"\r\n >\r\n <p>{{ 'igo.auth.welcome' | translate: user }}</p>\r\n <button mat-raised-button type=\"button\" (click)=\"logout()\">\r\n {{ 'igo.auth.signOut' | translate }}\r\n </button>\r\n </div>\r\n\r\n <div *ngIf=\"showLogoutDiv\" class=\"login center-block\">\r\n <p>{{ 'igo.auth.deconnection' | translate }}</p>\r\n <button\r\n *ngIf=\"options.homeRoute\"\r\n mat-raised-button\r\n type=\"button\"\r\n (click)=\"home()\"\r\n >\r\n {{ 'igo.auth.home' | translate }}\r\n </button>\r\n </div>\r\n</div>\r\n", styles: [":host{z-index:999}div.login{z-index:200;width:90%;min-width:360px;max-width:600px;padding:25px 50px;border:1px solid;background-color:#fff;border-color:#888}.center-block{position:fixed;top:20%;left:50%;transform:translate(-50%)}.backgroundDisable{position:fixed;top:0;left:0;background:#000;opacity:.8;z-index:100;height:100%;width:100%}\n"] }]
1067
+ }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router, decorators: [{
1068
+ type: Optional
1069
+ }] }]; }, { backgroundDisable: [{
1070
+ type: Input
1071
+ }], hasAlreadyConnectedDiv: [{
1072
+ type: Input
1073
+ }], hasLogoutDiv: [{
1074
+ type: Input
1075
+ }], showAlreadyConnectedDiv: [{
1076
+ type: Input
1077
+ }], showLogoutDiv: [{
1078
+ type: Input
1079
+ }], login: [{
1080
+ type: Output
1010
1081
  }] }); })();
1011
1082
 
1012
- class LoggedGuard {
1013
- constructor(authService, config, router) {
1014
- this.authService = authService;
1015
- this.config = config;
1016
- this.router = router;
1017
- }
1018
- canActivate(route, state) {
1019
- if (this.authService.logged) {
1020
- return true;
1021
- }
1022
- this.authService.redirectUrl = state.url;
1023
- const authConfig = this.config.getConfig('auth');
1024
- if (authConfig && authConfig.loginRoute) {
1025
- this.router.navigateByUrl(authConfig.loginRoute);
1026
- }
1027
- return false;
1028
- }
1029
- }
1030
- LoggedGuard.ɵfac = function LoggedGuard_Factory(t) { return new (t || LoggedGuard)(i0.ɵɵinject(AuthService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i3.Router)); };
1031
- LoggedGuard.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LoggedGuard, factory: LoggedGuard.ɵfac, providedIn: 'root' });
1032
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LoggedGuard, [{
1033
- type: Injectable,
1034
- args: [{
1035
- providedIn: 'root'
1036
- }]
1083
+ class LoggedGuard {
1084
+ authService;
1085
+ config;
1086
+ router;
1087
+ constructor(authService, config, router) {
1088
+ this.authService = authService;
1089
+ this.config = config;
1090
+ this.router = router;
1091
+ }
1092
+ canActivate(route, state) {
1093
+ if (this.authService.logged) {
1094
+ return true;
1095
+ }
1096
+ this.authService.redirectUrl = state.url;
1097
+ const authConfig = this.config.getConfig('auth');
1098
+ if (authConfig && authConfig.loginRoute) {
1099
+ this.router.navigateByUrl(authConfig.loginRoute);
1100
+ }
1101
+ return false;
1102
+ }
1103
+ static ɵfac = function LoggedGuard_Factory(t) { return new (t || LoggedGuard)(i0.ɵɵinject(AuthService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i3.Router)); };
1104
+ static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LoggedGuard, factory: LoggedGuard.ɵfac, providedIn: 'root' });
1105
+ }
1106
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LoggedGuard, [{
1107
+ type: Injectable,
1108
+ args: [{
1109
+ providedIn: 'root'
1110
+ }]
1037
1111
  }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router }]; }, null); })();
1038
1112
 
1039
- class AuthGuard {
1040
- constructor(authService, config, router) {
1041
- this.authService = authService;
1042
- this.config = config;
1043
- this.router = router;
1044
- }
1045
- canActivate(route, state) {
1046
- if (this.authService.authenticated) {
1047
- return true;
1048
- }
1049
- this.authService.redirectUrl = state.url;
1050
- const authConfig = this.config.getConfig('auth');
1051
- if (authConfig && authConfig.loginRoute) {
1052
- this.router.navigateByUrl(authConfig.loginRoute);
1053
- }
1054
- return false;
1055
- }
1056
- }
1057
- AuthGuard.ɵfac = function AuthGuard_Factory(t) { return new (t || AuthGuard)(i0.ɵɵinject(AuthService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i3.Router)); };
1058
- AuthGuard.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthGuard, factory: AuthGuard.ɵfac, providedIn: 'root' });
1059
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthGuard, [{
1060
- type: Injectable,
1061
- args: [{
1062
- providedIn: 'root'
1063
- }]
1113
+ class AuthGuard {
1114
+ authService;
1115
+ config;
1116
+ router;
1117
+ constructor(authService, config, router) {
1118
+ this.authService = authService;
1119
+ this.config = config;
1120
+ this.router = router;
1121
+ }
1122
+ canActivate(route, state) {
1123
+ if (this.authService.authenticated) {
1124
+ return true;
1125
+ }
1126
+ this.authService.redirectUrl = state.url;
1127
+ const authConfig = this.config.getConfig('auth');
1128
+ if (authConfig && authConfig.loginRoute) {
1129
+ this.router.navigateByUrl(authConfig.loginRoute);
1130
+ }
1131
+ return false;
1132
+ }
1133
+ static ɵfac = function AuthGuard_Factory(t) { return new (t || AuthGuard)(i0.ɵɵinject(AuthService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i3.Router)); };
1134
+ static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthGuard, factory: AuthGuard.ɵfac, providedIn: 'root' });
1135
+ }
1136
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthGuard, [{
1137
+ type: Injectable,
1138
+ args: [{
1139
+ providedIn: 'root'
1140
+ }]
1064
1141
  }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router }]; }, null); })();
1065
1142
 
1066
- class AdminGuard {
1067
- constructor(authService, config, router) {
1068
- this.authService = authService;
1069
- this.config = config;
1070
- this.router = router;
1071
- }
1072
- canActivate(route, state) {
1073
- const token = this.authService.decodeToken();
1074
- if (token && token.user && token.user.isAdmin) {
1075
- return true;
1076
- }
1077
- this.authService.redirectUrl = state.url;
1078
- const authConfig = this.config.getConfig('auth');
1079
- if (authConfig && authConfig.loginRoute) {
1080
- this.router.navigateByUrl(authConfig.loginRoute);
1081
- }
1082
- return false;
1083
- }
1084
- }
1085
- AdminGuard.ɵfac = function AdminGuard_Factory(t) { return new (t || AdminGuard)(i0.ɵɵinject(AuthService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i3.Router)); };
1086
- AdminGuard.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AdminGuard, factory: AdminGuard.ɵfac, providedIn: 'root' });
1087
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AdminGuard, [{
1088
- type: Injectable,
1089
- args: [{
1090
- providedIn: 'root'
1091
- }]
1143
+ class AdminGuard {
1144
+ authService;
1145
+ config;
1146
+ router;
1147
+ constructor(authService, config, router) {
1148
+ this.authService = authService;
1149
+ this.config = config;
1150
+ this.router = router;
1151
+ }
1152
+ canActivate(route, state) {
1153
+ const token = this.authService.decodeToken();
1154
+ if (token && token.user && token.user.isAdmin) {
1155
+ return true;
1156
+ }
1157
+ this.authService.redirectUrl = state.url;
1158
+ const authConfig = this.config.getConfig('auth');
1159
+ if (authConfig && authConfig.loginRoute) {
1160
+ this.router.navigateByUrl(authConfig.loginRoute);
1161
+ }
1162
+ return false;
1163
+ }
1164
+ static ɵfac = function AdminGuard_Factory(t) { return new (t || AdminGuard)(i0.ɵɵinject(AuthService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i3.Router)); };
1165
+ static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AdminGuard, factory: AdminGuard.ɵfac, providedIn: 'root' });
1166
+ }
1167
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AdminGuard, [{
1168
+ type: Injectable,
1169
+ args: [{
1170
+ providedIn: 'root'
1171
+ }]
1092
1172
  }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router }]; }, null); })();
1093
1173
 
1094
- class ProfilsGuard {
1095
- constructor(authService, config, router) {
1096
- this.authService = authService;
1097
- this.config = config;
1098
- this.router = router;
1099
- }
1100
- canActivate(_route, state) {
1101
- return this.authService.getProfils().pipe(map((profils) => {
1102
- const authConfig = this.config.getConfig('auth');
1103
- if (profils &&
1104
- profils.profils &&
1105
- profils.profils.some(v => authConfig.profilsGuard.indexOf(v) !== -1)) {
1106
- return true;
1107
- }
1108
- this.authService.redirectUrl = state.url;
1109
- if (authConfig && authConfig.loginRoute) {
1110
- this.router.navigateByUrl(authConfig.loginRoute);
1111
- }
1112
- return false;
1113
- }));
1114
- }
1115
- }
1116
- ProfilsGuard.ɵfac = function ProfilsGuard_Factory(t) { return new (t || ProfilsGuard)(i0.ɵɵinject(AuthService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i3.Router)); };
1117
- ProfilsGuard.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ProfilsGuard, factory: ProfilsGuard.ɵfac, providedIn: 'root' });
1118
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ProfilsGuard, [{
1119
- type: Injectable,
1120
- args: [{
1121
- providedIn: 'root'
1122
- }]
1174
+ class ProfilsGuard {
1175
+ authService;
1176
+ config;
1177
+ router;
1178
+ constructor(authService, config, router) {
1179
+ this.authService = authService;
1180
+ this.config = config;
1181
+ this.router = router;
1182
+ }
1183
+ canActivate(_route, state) {
1184
+ return this.authService.getProfils().pipe(map((profils) => {
1185
+ const authConfig = this.config.getConfig('auth');
1186
+ if (profils &&
1187
+ profils.profils &&
1188
+ profils.profils.some((v) => authConfig.profilsGuard.indexOf(v) !== -1)) {
1189
+ return true;
1190
+ }
1191
+ this.authService.redirectUrl = state.url;
1192
+ if (authConfig && authConfig.loginRoute) {
1193
+ this.router.navigateByUrl(authConfig.loginRoute);
1194
+ }
1195
+ return false;
1196
+ }));
1197
+ }
1198
+ static ɵfac = function ProfilsGuard_Factory(t) { return new (t || ProfilsGuard)(i0.ɵɵinject(AuthService), i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i3.Router)); };
1199
+ static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ProfilsGuard, factory: ProfilsGuard.ɵfac, providedIn: 'root' });
1200
+ }
1201
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ProfilsGuard, [{
1202
+ type: Injectable,
1203
+ args: [{
1204
+ providedIn: 'root'
1205
+ }]
1123
1206
  }], function () { return [{ type: AuthService }, { type: i2.ConfigService }, { type: i3.Router }]; }, null); })();
1124
1207
 
1125
- class AuthInterceptor {
1126
- constructor(config, tokenService, http) {
1127
- this.config = config;
1128
- this.tokenService = tokenService;
1129
- this.http = http;
1130
- this.refreshInProgress = false;
1131
- }
1132
- get trustHosts() {
1133
- const trustHosts = this.config.getConfig('auth.trustHosts') || [];
1134
- trustHosts.push(window.location.hostname);
1135
- return trustHosts;
1136
- }
1137
- get hostsWithCredentials() {
1138
- return this.config.getConfig('auth.hostsWithCredentials') || [];
1139
- }
1140
- get hostsWithAuthByKey() {
1141
- return this.config.getConfig('auth.hostsByKey') || [];
1142
- }
1143
- intercept(originalReq, next) {
1144
- const withCredentials = this.handleHostsWithCredentials(originalReq.url);
1145
- let req = originalReq.clone();
1146
- const hostWithKey = this.handleHostsAuthByKey(originalReq.url);
1147
- if (hostWithKey) {
1148
- req = req.clone({
1149
- params: req.params.set(hostWithKey.key, hostWithKey.value)
1150
- });
1151
- }
1152
- if (withCredentials) {
1153
- req = originalReq.clone({
1154
- withCredentials
1155
- });
1156
- return next.handle(req);
1157
- }
1158
- this.refreshToken();
1159
- const token = this.tokenService.get();
1160
- const element = document.createElement('a');
1161
- element.href = req.url;
1162
- if (element.host === '') {
1163
- element.href = element.href; // FIX IE11, DO NOT REMOVE
1164
- }
1165
- if (!token || this.trustHosts.indexOf(element.hostname) === -1) {
1166
- return next.handle(req);
1167
- }
1168
- const authHeader = `Bearer ${token}`;
1169
- let authReq = req.clone({
1170
- headers: req.headers.set('Authorization', authHeader)
1171
- });
1172
- const tokenDecoded = this.tokenService.decode();
1173
- if (authReq.params.get('_i') === 'true' &&
1174
- tokenDecoded &&
1175
- tokenDecoded.user &&
1176
- tokenDecoded.user.sourceId) {
1177
- const hashUser = Md5.hashStr(tokenDecoded.user.sourceId);
1178
- authReq = authReq.clone({
1179
- params: authReq.params.set('_i', hashUser)
1180
- });
1181
- }
1182
- else if (authReq.params.get('_i') === 'true') {
1183
- authReq = authReq.clone({
1184
- params: authReq.params.delete('_i')
1185
- });
1186
- }
1187
- return next.handle(authReq);
1188
- }
1189
- interceptXhr(xhr, url) {
1190
- const withCredentials = this.handleHostsWithCredentials(url);
1191
- if (withCredentials) {
1192
- xhr.withCredentials = withCredentials;
1193
- return true;
1194
- }
1195
- this.refreshToken();
1196
- const element = document.createElement('a');
1197
- element.href = url;
1198
- const token = this.tokenService.get();
1199
- if (!token || this.trustHosts.indexOf(element.hostname) === -1) {
1200
- return false;
1201
- }
1202
- xhr.setRequestHeader('Authorization', 'Bearer ' + token);
1203
- return true;
1204
- }
1205
- alterUrlWithKeyAuth(url) {
1206
- const hostWithKey = this.handleHostsAuthByKey(url);
1207
- let interceptedUrl = url;
1208
- if (hostWithKey) {
1209
- const urlDecomposed = interceptedUrl.split(/[?&]/);
1210
- let urlWithKeyAdded = urlDecomposed.shift();
1211
- const paramsToKeep = urlDecomposed.filter(p => p.length !== 0);
1212
- paramsToKeep.push(`${hostWithKey.key}=${hostWithKey.value}`);
1213
- if (paramsToKeep.length) {
1214
- urlWithKeyAdded += '?' + paramsToKeep.join('&');
1215
- }
1216
- return urlWithKeyAdded;
1217
- }
1218
- return;
1219
- }
1220
- handleHostsWithCredentials(reqUrl) {
1221
- let withCredentials = false;
1222
- for (const hostWithCredentials of this.hostsWithCredentials) {
1223
- const domainRegex = new RegExp(hostWithCredentials.domainRegFilters);
1224
- if (domainRegex.test(reqUrl)) {
1225
- withCredentials = hostWithCredentials.withCredentials !== undefined ? hostWithCredentials.withCredentials : undefined;
1226
- break;
1227
- }
1228
- }
1229
- return withCredentials;
1230
- }
1231
- handleHostsAuthByKey(reqUrl) {
1232
- let hostWithKey;
1233
- for (const hostWithAuthByKey of this.hostsWithAuthByKey) {
1234
- const domainRegex = new RegExp(hostWithAuthByKey.domainRegFilters);
1235
- if (domainRegex.test(reqUrl)) {
1236
- var replace = `${hostWithAuthByKey.keyProperty}=${hostWithAuthByKey.keyValue}`;
1237
- var keyAdded = new RegExp(replace, "gm");
1238
- if (!keyAdded.test(reqUrl)) {
1239
- hostWithKey = { key: hostWithAuthByKey.keyProperty, value: hostWithAuthByKey.keyValue };
1240
- break;
1241
- }
1242
- }
1243
- }
1244
- return hostWithKey;
1245
- }
1246
- refreshToken() {
1247
- const jwt = this.tokenService.decode();
1248
- const currentTime = new Date().getTime() / 1000;
1249
- if (!this.refreshInProgress &&
1250
- jwt &&
1251
- currentTime < jwt.exp &&
1252
- currentTime > jwt.exp - 1800) {
1253
- this.refreshInProgress = true;
1254
- const url = this.config.getConfig('auth.url');
1255
- return this.http.post(`${url}/refresh`, {}).subscribe((data) => {
1256
- this.tokenService.set(data.token);
1257
- this.refreshInProgress = false;
1258
- }, err => {
1259
- err.error.caught = true;
1260
- return err;
1261
- });
1262
- }
1263
- }
1264
- }
1265
- AuthInterceptor.ɵfac = function AuthInterceptor_Factory(t) { return new (t || AuthInterceptor)(i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(TokenService), i0.ɵɵinject(i1.HttpClient)); };
1266
- AuthInterceptor.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthInterceptor, factory: AuthInterceptor.ɵfac, providedIn: 'root' });
1267
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthInterceptor, [{
1268
- type: Injectable,
1269
- args: [{
1270
- providedIn: 'root'
1271
- }]
1208
+ class AuthInterceptor {
1209
+ config;
1210
+ tokenService;
1211
+ http;
1212
+ refreshInProgress = false;
1213
+ trustHosts;
1214
+ hostsWithCredentials;
1215
+ hostsWithAuthByKey;
1216
+ constructor(config, tokenService, http) {
1217
+ this.config = config;
1218
+ this.tokenService = tokenService;
1219
+ this.http = http;
1220
+ this.trustHosts = this.config.getConfig('auth.trustHosts') || [];
1221
+ this.trustHosts.push(window.location.hostname);
1222
+ this.hostsWithCredentials =
1223
+ this.config.getConfig('auth.hostsWithCredentials') || [];
1224
+ this.hostsWithAuthByKey = this.config.getConfig('auth.hostsByKey') || [];
1225
+ }
1226
+ intercept(originalReq, next) {
1227
+ const withCredentials = this.handleHostsWithCredentials(originalReq.url);
1228
+ let req = originalReq.clone();
1229
+ const hostWithKey = this.handleHostsAuthByKey(originalReq.url);
1230
+ if (hostWithKey) {
1231
+ req = req.clone({
1232
+ params: req.params.set(hostWithKey.key, hostWithKey.value)
1233
+ });
1234
+ }
1235
+ if (withCredentials) {
1236
+ req = originalReq.clone({
1237
+ withCredentials
1238
+ });
1239
+ return next.handle(req);
1240
+ }
1241
+ this.refreshToken();
1242
+ const token = this.tokenService.get();
1243
+ const element = document.createElement('a');
1244
+ element.href = req.url;
1245
+ if (element.host === '') {
1246
+ element.href = element.href; // FIX IE11, DO NOT REMOVE
1247
+ }
1248
+ if (!token || this.trustHosts.indexOf(element.hostname) === -1) {
1249
+ return next.handle(req);
1250
+ }
1251
+ const authHeader = `Bearer ${token}`;
1252
+ let authReq = req.clone({
1253
+ headers: req.headers.set('Authorization', authHeader)
1254
+ });
1255
+ const tokenDecoded = this.tokenService.decode();
1256
+ if (authReq.params.get('_i') === 'true' &&
1257
+ tokenDecoded &&
1258
+ tokenDecoded.user &&
1259
+ tokenDecoded.user.sourceId) {
1260
+ const hashUser = Md5.hashStr(tokenDecoded.user.sourceId);
1261
+ authReq = authReq.clone({
1262
+ params: authReq.params.set('_i', hashUser)
1263
+ });
1264
+ }
1265
+ else if (authReq.params.get('_i') === 'true') {
1266
+ authReq = authReq.clone({
1267
+ params: authReq.params.delete('_i')
1268
+ });
1269
+ }
1270
+ return next.handle(authReq);
1271
+ }
1272
+ interceptXhr(xhr, url) {
1273
+ const withCredentials = this.handleHostsWithCredentials(url);
1274
+ if (withCredentials) {
1275
+ xhr.withCredentials = withCredentials;
1276
+ return true;
1277
+ }
1278
+ this.refreshToken();
1279
+ const element = document.createElement('a');
1280
+ element.href = url;
1281
+ const token = this.tokenService.get();
1282
+ if (!token || this.trustHosts.indexOf(element.hostname) === -1) {
1283
+ return false;
1284
+ }
1285
+ xhr.setRequestHeader('Authorization', 'Bearer ' + token);
1286
+ return true;
1287
+ }
1288
+ alterUrlWithKeyAuth(url) {
1289
+ const hostWithKey = this.handleHostsAuthByKey(url);
1290
+ let interceptedUrl = url;
1291
+ if (hostWithKey) {
1292
+ const urlDecomposed = interceptedUrl.split(/[?&]/);
1293
+ let urlWithKeyAdded = urlDecomposed.shift();
1294
+ const paramsToKeep = urlDecomposed.filter((p) => p.length !== 0);
1295
+ paramsToKeep.push(`${hostWithKey.key}=${hostWithKey.value}`);
1296
+ if (paramsToKeep.length) {
1297
+ urlWithKeyAdded += '?' + paramsToKeep.join('&');
1298
+ }
1299
+ return urlWithKeyAdded;
1300
+ }
1301
+ return;
1302
+ }
1303
+ handleHostsWithCredentials(reqUrl) {
1304
+ let withCredentials = false;
1305
+ for (const hostWithCredentials of this.hostsWithCredentials) {
1306
+ const domainRegex = new RegExp(hostWithCredentials.domainRegFilters);
1307
+ if (domainRegex.test(reqUrl)) {
1308
+ withCredentials =
1309
+ hostWithCredentials.withCredentials !== undefined
1310
+ ? hostWithCredentials.withCredentials
1311
+ : undefined;
1312
+ break;
1313
+ }
1314
+ }
1315
+ return withCredentials;
1316
+ }
1317
+ handleHostsAuthByKey(reqUrl) {
1318
+ let hostWithKey;
1319
+ for (const hostWithAuthByKey of this.hostsWithAuthByKey) {
1320
+ const domainRegex = new RegExp(hostWithAuthByKey.domainRegFilters);
1321
+ if (domainRegex.test(reqUrl)) {
1322
+ var replace = `${hostWithAuthByKey.keyProperty}=${hostWithAuthByKey.keyValue}`;
1323
+ var keyAdded = new RegExp(replace, 'gm');
1324
+ if (!keyAdded.test(reqUrl)) {
1325
+ hostWithKey = {
1326
+ key: hostWithAuthByKey.keyProperty,
1327
+ value: hostWithAuthByKey.keyValue
1328
+ };
1329
+ break;
1330
+ }
1331
+ }
1332
+ }
1333
+ return hostWithKey;
1334
+ }
1335
+ refreshToken() {
1336
+ const jwt = this.tokenService.decode();
1337
+ const currentTime = new Date().getTime() / 1000;
1338
+ if (!this.refreshInProgress &&
1339
+ jwt &&
1340
+ currentTime < jwt.exp &&
1341
+ currentTime > jwt.exp - 1800) {
1342
+ this.refreshInProgress = true;
1343
+ const url = this.config.getConfig('auth.url');
1344
+ return this.http.post(`${url}/refresh`, {}).subscribe((data) => {
1345
+ this.tokenService.set(data.token);
1346
+ this.refreshInProgress = false;
1347
+ }, (err) => {
1348
+ err.error.caught = true;
1349
+ return err;
1350
+ });
1351
+ }
1352
+ }
1353
+ static ɵfac = function AuthInterceptor_Factory(t) { return new (t || AuthInterceptor)(i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(TokenService), i0.ɵɵinject(i1.HttpClient)); };
1354
+ static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthInterceptor, factory: AuthInterceptor.ɵfac, providedIn: 'root' });
1355
+ }
1356
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthInterceptor, [{
1357
+ type: Injectable,
1358
+ args: [{
1359
+ providedIn: 'root'
1360
+ }]
1272
1361
  }], function () { return [{ type: i2.ConfigService }, { type: TokenService }, { type: i1.HttpClient }]; }, null); })();
1273
1362
 
1274
- function MSALConfigFactory(config) {
1275
- const msConf = config.getConfig('auth.microsoft') || {};
1276
- msConf.redirectUri = msConf.redirectUri || window.location.href;
1277
- msConf.authority = msConf.authority || 'https://login.microsoftonline.com/organizations';
1278
- const myMsalObj = new PublicClientApplication({
1279
- auth: msConf,
1280
- cache: {
1281
- cacheLocation: 'sessionStorage'
1282
- }
1283
- });
1284
- return myMsalObj;
1285
- }
1286
- function MSALConfigFactoryb2c(config) {
1287
- const msConf = config.getConfig('auth.microsoftb2c.browserAuthOptions') || {};
1288
- msConf.redirectUri = msConf.redirectUri || window.location.href;
1289
- msConf.authority = msConf.authority || 'https://login.microsoftonline.com/organizations';
1290
- const myMsalObj = new PublicClientApplication({
1291
- auth: msConf,
1292
- cache: {
1293
- cacheLocation: 'sessionStorage'
1294
- }
1295
- });
1296
- return myMsalObj;
1297
- }
1298
- function MSALAngularConfigFactory(config) {
1299
- const msConf = config.getConfig('auth.microsoft') || {};
1300
- return {
1301
- interactionType: InteractionType.Popup,
1302
- authRequest: {
1303
- scopes: ['user.read'],
1304
- loginHint: 'todo',
1305
- },
1306
- type: 'add'
1307
- };
1308
- }
1309
- function MSALAngularConfigFactoryb2c(config) {
1310
- const msConf = config.getConfig('auth.microsoftb2c.browserAuthOptions') || {};
1311
- return {
1312
- interactionType: InteractionType.Popup,
1313
- authRequest: {
1314
- scopes: [msConf.clientId]
1315
- },
1316
- type: 'b2c'
1317
- };
1318
- }
1319
- function provideAuthMicrosoft(type) {
1320
- if (type === 'b2c') {
1321
- return [
1322
- {
1323
- provide: MSAL_INSTANCE,
1324
- useFactory: MSALConfigFactoryb2c,
1325
- deps: [ConfigService]
1326
- },
1327
- {
1328
- provide: MSAL_GUARD_CONFIG,
1329
- useFactory: MSALAngularConfigFactoryb2c,
1330
- deps: [ConfigService],
1331
- multi: true
1332
- },
1333
- MsalServiceb2c
1334
- ];
1335
- }
1336
- else {
1337
- return [
1338
- {
1339
- provide: MSAL_INSTANCE,
1340
- useFactory: MSALConfigFactory,
1341
- deps: [ConfigService]
1342
- },
1343
- {
1344
- provide: MSAL_GUARD_CONFIG,
1345
- useFactory: MSALAngularConfigFactory,
1346
- deps: [ConfigService],
1347
- multi: true
1348
- },
1349
- MsalService
1350
- ];
1351
- }
1363
+ function MSALConfigFactory(config) {
1364
+ const msConf = config.getConfig('auth.microsoft');
1365
+ msConf.redirectUri = msConf?.redirectUri || window.location.href;
1366
+ msConf.authority =
1367
+ msConf?.authority || 'https://login.microsoftonline.com/organizations';
1368
+ const myMsalObj = new PublicClientApplication({
1369
+ auth: msConf,
1370
+ cache: {
1371
+ cacheLocation: 'sessionStorage'
1372
+ }
1373
+ });
1374
+ return myMsalObj;
1375
+ }
1376
+ function MSALConfigFactoryb2c(config) {
1377
+ const msConf = config.getConfig('auth.microsoftb2c.browserAuthOptions');
1378
+ msConf.redirectUri = msConf?.redirectUri || window.location.href;
1379
+ msConf.authority =
1380
+ msConf?.authority || 'https://login.microsoftonline.com/organizations';
1381
+ const myMsalObj = new PublicClientApplication({
1382
+ auth: msConf,
1383
+ cache: {
1384
+ cacheLocation: 'sessionStorage'
1385
+ }
1386
+ });
1387
+ return myMsalObj;
1388
+ }
1389
+ function MSALAngularConfigFactory(config) {
1390
+ const msConf = config.getConfig('auth.microsoft');
1391
+ return {
1392
+ interactionType: InteractionType.Popup,
1393
+ authRequest: {
1394
+ scopes: ['user.read'],
1395
+ loginHint: 'todo'
1396
+ },
1397
+ type: 'add'
1398
+ };
1399
+ }
1400
+ function MSALAngularConfigFactoryb2c(config) {
1401
+ const msConf = config.getConfig('auth.microsoftb2c.browserAuthOptions');
1402
+ return {
1403
+ interactionType: InteractionType.Popup,
1404
+ authRequest: {
1405
+ scopes: [msConf?.clientId]
1406
+ },
1407
+ type: 'b2c'
1408
+ };
1409
+ }
1410
+ function provideAuthMicrosoft(type) {
1411
+ if (type === 'b2c') {
1412
+ return [
1413
+ {
1414
+ provide: MSAL_INSTANCE,
1415
+ useFactory: MSALConfigFactoryb2c,
1416
+ deps: [ConfigService]
1417
+ },
1418
+ {
1419
+ provide: MSAL_GUARD_CONFIG,
1420
+ useFactory: MSALAngularConfigFactoryb2c,
1421
+ deps: [ConfigService],
1422
+ multi: true
1423
+ },
1424
+ MsalServiceb2c
1425
+ ];
1426
+ }
1427
+ else {
1428
+ return [
1429
+ {
1430
+ provide: MSAL_INSTANCE,
1431
+ useFactory: MSALConfigFactory,
1432
+ deps: [ConfigService]
1433
+ },
1434
+ {
1435
+ provide: MSAL_GUARD_CONFIG,
1436
+ useFactory: MSALAngularConfigFactory,
1437
+ deps: [ConfigService],
1438
+ multi: true
1439
+ },
1440
+ MsalService
1441
+ ];
1442
+ }
1352
1443
  }
1353
1444
 
1354
- class ProtectedDirective {
1355
- constructor(authentication, el) {
1356
- if (!authentication.isAuthenticated()) {
1357
- el.nativeElement.parentNode.removeChild(el.nativeElement);
1358
- }
1359
- }
1360
- }
1361
- ProtectedDirective.ɵfac = function ProtectedDirective_Factory(t) { return new (t || ProtectedDirective)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i0.ElementRef)); };
1362
- ProtectedDirective.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: ProtectedDirective, selectors: [["", "igoProtected", ""]] });
1363
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ProtectedDirective, [{
1364
- type: Directive,
1365
- args: [{
1366
- selector: '[igoProtected]'
1367
- }]
1445
+ class ProtectedDirective {
1446
+ constructor(authentication, el) {
1447
+ if (!authentication.isAuthenticated()) {
1448
+ el.nativeElement.parentNode.removeChild(el.nativeElement);
1449
+ }
1450
+ }
1451
+ static ɵfac = function ProtectedDirective_Factory(t) { return new (t || ProtectedDirective)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i0.ElementRef)); };
1452
+ static ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: ProtectedDirective, selectors: [["", "igoProtected", ""]] });
1453
+ }
1454
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ProtectedDirective, [{
1455
+ type: Directive,
1456
+ args: [{
1457
+ selector: '[igoProtected]'
1458
+ }]
1368
1459
  }], function () { return [{ type: AuthService }, { type: i0.ElementRef }]; }, null); })();
1369
1460
 
1370
- class AuthStorageService extends StorageService {
1371
- constructor(config, http, authService, tokenService) {
1372
- super(config);
1373
- this.http = http;
1374
- this.authService = authService;
1375
- this.tokenService = tokenService;
1376
- this.authService.authenticate$.subscribe(isAuthenticated => {
1377
- if (isAuthenticated && this.options.url) {
1378
- this.http
1379
- .get(this.options.url)
1380
- .subscribe((userIgo) => {
1381
- if (userIgo && userIgo.preference) {
1382
- for (const key of Object.keys(userIgo.preference)) {
1383
- const value = userIgo.preference[key];
1384
- super.set(key, value);
1385
- }
1386
- }
1387
- });
1388
- }
1389
- });
1390
- }
1391
- set(key, value, scope = StorageScope.LOCAL) {
1392
- if (scope === StorageScope.LOCAL &&
1393
- this.authService.authenticated &&
1394
- this.options.url) {
1395
- const preference = {};
1396
- preference[key] = value;
1397
- this.http.patch(this.options.url, { preference }).subscribe();
1398
- }
1399
- super.set(key, value, scope);
1400
- }
1401
- remove(key, scope = StorageScope.LOCAL) {
1402
- if (scope === StorageScope.LOCAL &&
1403
- this.authService.authenticated &&
1404
- this.options.url) {
1405
- const preference = {};
1406
- preference[key] = undefined;
1407
- this.http.patch(this.options.url, { preference }).subscribe();
1408
- }
1409
- super.remove(key, scope);
1410
- }
1411
- clear(scope = StorageScope.LOCAL) {
1412
- if (scope === StorageScope.LOCAL &&
1413
- this.authService.authenticated &&
1414
- this.options.url) {
1415
- this.http.patch(this.options.url, { preference: {} }, {
1416
- params: {
1417
- mergePreference: 'false'
1418
- }
1419
- }).subscribe();
1420
- }
1421
- let token;
1422
- if (scope === StorageScope.LOCAL) {
1423
- token = this.tokenService.get();
1424
- }
1425
- super.clear(scope);
1426
- if (token) {
1427
- this.tokenService.set(token);
1428
- }
1429
- if (scope === StorageScope.LOCAL &&
1430
- this.authService.authenticated &&
1431
- this.options.url) {
1432
- this.http
1433
- .get(this.options.url)
1434
- .subscribe((userIgo) => {
1435
- if (userIgo && userIgo.preference) {
1436
- for (const key of Object.keys(userIgo.preference)) {
1437
- const value = userIgo.preference[key];
1438
- super.set(key, value);
1439
- }
1440
- }
1441
- });
1442
- }
1443
- }
1444
- }
1445
- AuthStorageService.ɵfac = function AuthStorageService_Factory(t) { return new (t || AuthStorageService)(i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(AuthService), i0.ɵɵinject(TokenService)); };
1446
- AuthStorageService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthStorageService, factory: AuthStorageService.ɵfac, providedIn: 'root' });
1447
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthStorageService, [{
1448
- type: Injectable,
1449
- args: [{
1450
- providedIn: 'root'
1451
- }]
1461
+ class AuthStorageService extends BaseStorage {
1462
+ http;
1463
+ authService;
1464
+ tokenService;
1465
+ constructor(config, http, authService, tokenService) {
1466
+ super(config);
1467
+ this.http = http;
1468
+ this.authService = authService;
1469
+ this.tokenService = tokenService;
1470
+ this.authService.authenticate$.subscribe((isAuthenticated) => {
1471
+ if (isAuthenticated && this.options.url) {
1472
+ this.http
1473
+ .get(this.options.url)
1474
+ .subscribe((userIgo) => {
1475
+ if (userIgo && userIgo.preference) {
1476
+ for (const key of Object.keys(userIgo.preference)) {
1477
+ const value = userIgo.preference[key];
1478
+ super.set(key, value);
1479
+ }
1480
+ }
1481
+ });
1482
+ }
1483
+ });
1484
+ }
1485
+ set(key, value, scope = StorageScope.LOCAL) {
1486
+ if (scope === StorageScope.LOCAL &&
1487
+ this.authService.authenticated &&
1488
+ this.options.url) {
1489
+ const preference = {};
1490
+ preference[key] = value;
1491
+ this.http.patch(this.options.url, { preference }).subscribe();
1492
+ }
1493
+ super.set(key, value, scope);
1494
+ }
1495
+ remove(key, scope = StorageScope.LOCAL) {
1496
+ if (scope === StorageScope.LOCAL &&
1497
+ this.authService.authenticated &&
1498
+ this.options.url) {
1499
+ const preference = {};
1500
+ preference[key] = undefined;
1501
+ this.http.patch(this.options.url, { preference }).subscribe();
1502
+ }
1503
+ super.remove(key, scope);
1504
+ }
1505
+ clear(scope = StorageScope.LOCAL) {
1506
+ if (scope === StorageScope.LOCAL &&
1507
+ this.authService.authenticated &&
1508
+ this.options.url) {
1509
+ this.http
1510
+ .patch(this.options.url, { preference: {} }, {
1511
+ params: {
1512
+ mergePreference: 'false'
1513
+ }
1514
+ })
1515
+ .subscribe();
1516
+ }
1517
+ let token;
1518
+ if (scope === StorageScope.LOCAL) {
1519
+ token = this.tokenService.get();
1520
+ }
1521
+ super.clear(scope);
1522
+ if (token) {
1523
+ this.tokenService.set(token);
1524
+ }
1525
+ if (scope === StorageScope.LOCAL &&
1526
+ this.authService.authenticated &&
1527
+ this.options.url) {
1528
+ this.http
1529
+ .get(this.options.url)
1530
+ .subscribe((userIgo) => {
1531
+ if (userIgo && userIgo.preference) {
1532
+ for (const key of Object.keys(userIgo.preference)) {
1533
+ const value = userIgo.preference[key];
1534
+ super.set(key, value);
1535
+ }
1536
+ }
1537
+ });
1538
+ }
1539
+ }
1540
+ static ɵfac = function AuthStorageService_Factory(t) { return new (t || AuthStorageService)(i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(AuthService), i0.ɵɵinject(TokenService)); };
1541
+ static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthStorageService, factory: AuthStorageService.ɵfac, providedIn: 'root' });
1542
+ }
1543
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthStorageService, [{
1544
+ type: Injectable,
1545
+ args: [{
1546
+ providedIn: 'root'
1547
+ }]
1452
1548
  }], function () { return [{ type: i2.ConfigService }, { type: i1.HttpClient }, { type: AuthService }, { type: TokenService }]; }, null); })();
1453
1549
 
1454
- const routes = [
1455
- { path: 'login', component: AuthFormComponent },
1456
- { path: 'logout', component: AuthFormComponent }
1457
- ];
1458
- class AuthRoutingModule {
1459
- }
1460
- AuthRoutingModule.ɵfac = function AuthRoutingModule_Factory(t) { return new (t || AuthRoutingModule)(); };
1461
- AuthRoutingModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: AuthRoutingModule });
1462
- AuthRoutingModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [RouterModule.forChild(routes), RouterModule] });
1463
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthRoutingModule, [{
1464
- type: NgModule,
1465
- args: [{
1466
- imports: [RouterModule.forChild(routes)],
1467
- exports: [RouterModule],
1468
- providers: []
1469
- }]
1470
- }], null, null); })();
1550
+ const routes = [
1551
+ { path: 'login', component: AuthFormComponent },
1552
+ { path: 'logout', component: AuthFormComponent }
1553
+ ];
1554
+ class AuthRoutingModule {
1555
+ static ɵfac = function AuthRoutingModule_Factory(t) { return new (t || AuthRoutingModule)(); };
1556
+ static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: AuthRoutingModule });
1557
+ static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [RouterModule.forChild(routes), RouterModule] });
1558
+ }
1559
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthRoutingModule, [{
1560
+ type: NgModule,
1561
+ args: [{
1562
+ imports: [RouterModule.forChild(routes)],
1563
+ exports: [RouterModule],
1564
+ providers: []
1565
+ }]
1566
+ }], null, null); })();
1471
1567
  (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(AuthRoutingModule, { imports: [i3.RouterModule], exports: [RouterModule] }); })();
1472
1568
 
1473
- class IgoAuthModule {
1474
- static forRoot() {
1475
- return {
1476
- ngModule: IgoAuthModule,
1477
- providers: [
1478
- {
1479
- provide: HTTP_INTERCEPTORS,
1480
- useClass: AuthInterceptor,
1481
- multi: true
1482
- },
1483
- {
1484
- provide: StorageService,
1485
- useClass: AuthStorageService
1486
- },
1487
- ...provideAuthMicrosoft('add'),
1488
- ...provideAuthMicrosoft('b2c')
1489
- ]
1490
- };
1491
- }
1492
- }
1493
- IgoAuthModule.ɵfac = function IgoAuthModule_Factory(t) { return new (t || IgoAuthModule)(); };
1494
- IgoAuthModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoAuthModule });
1495
- IgoAuthModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
1496
- ReactiveFormsModule,
1497
- MatFormFieldModule,
1498
- MatInputModule,
1499
- MatIconModule,
1500
- MatButtonModule,
1501
- IgoLanguageModule,
1502
- MsalModule] });
1503
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoAuthModule, [{
1504
- type: NgModule,
1505
- args: [{
1506
- imports: [
1507
- CommonModule,
1508
- ReactiveFormsModule,
1509
- MatFormFieldModule,
1510
- MatInputModule,
1511
- MatIconModule,
1512
- MatButtonModule,
1513
- IgoLanguageModule,
1514
- MsalModule
1515
- ],
1516
- declarations: [
1517
- AuthFormComponent,
1518
- AuthGoogleComponent,
1519
- AuthInternComponent,
1520
- AuthFacebookComponent,
1521
- AuthMicrosoftComponent,
1522
- AuthMicrosoftb2cComponent,
1523
- ProtectedDirective
1524
- ],
1525
- exports: [AuthFormComponent, ProtectedDirective]
1526
- }]
1527
- }], null, null); })();
1528
- (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(IgoAuthModule, { declarations: [AuthFormComponent,
1529
- AuthGoogleComponent,
1530
- AuthInternComponent,
1531
- AuthFacebookComponent,
1532
- AuthMicrosoftComponent,
1533
- AuthMicrosoftb2cComponent,
1534
- ProtectedDirective], imports: [CommonModule,
1535
- ReactiveFormsModule,
1536
- MatFormFieldModule,
1537
- MatInputModule,
1538
- MatIconModule,
1539
- MatButtonModule,
1540
- IgoLanguageModule,
1569
+ class IgoAuthModule {
1570
+ static forRoot() {
1571
+ return {
1572
+ ngModule: IgoAuthModule,
1573
+ providers: [
1574
+ {
1575
+ provide: HTTP_INTERCEPTORS,
1576
+ useClass: AuthInterceptor,
1577
+ multi: true
1578
+ },
1579
+ {
1580
+ provide: StorageService,
1581
+ useClass: AuthStorageService
1582
+ },
1583
+ ...provideAuthMicrosoft('add'),
1584
+ ...provideAuthMicrosoft('b2c')
1585
+ ]
1586
+ };
1587
+ }
1588
+ static ɵfac = function IgoAuthModule_Factory(t) { return new (t || IgoAuthModule)(); };
1589
+ static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoAuthModule });
1590
+ static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
1591
+ ReactiveFormsModule,
1592
+ MatFormFieldModule,
1593
+ MatInputModule,
1594
+ MatIconModule,
1595
+ MatButtonModule,
1596
+ IgoLanguageModule,
1597
+ MsalModule] });
1598
+ }
1599
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoAuthModule, [{
1600
+ type: NgModule,
1601
+ args: [{
1602
+ imports: [
1603
+ CommonModule,
1604
+ ReactiveFormsModule,
1605
+ MatFormFieldModule,
1606
+ MatInputModule,
1607
+ MatIconModule,
1608
+ MatButtonModule,
1609
+ IgoLanguageModule,
1610
+ MsalModule
1611
+ ],
1612
+ declarations: [
1613
+ AuthFormComponent,
1614
+ AuthGoogleComponent,
1615
+ AuthInternComponent,
1616
+ AuthFacebookComponent,
1617
+ AuthMicrosoftComponent,
1618
+ AuthMicrosoftb2cComponent,
1619
+ ProtectedDirective
1620
+ ],
1621
+ exports: [AuthFormComponent, ProtectedDirective]
1622
+ }]
1623
+ }], null, null); })();
1624
+ (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(IgoAuthModule, { declarations: [AuthFormComponent,
1625
+ AuthGoogleComponent,
1626
+ AuthInternComponent,
1627
+ AuthFacebookComponent,
1628
+ AuthMicrosoftComponent,
1629
+ AuthMicrosoftb2cComponent,
1630
+ ProtectedDirective], imports: [CommonModule,
1631
+ ReactiveFormsModule,
1632
+ MatFormFieldModule,
1633
+ MatInputModule,
1634
+ MatIconModule,
1635
+ MatButtonModule,
1636
+ IgoLanguageModule,
1541
1637
  MsalModule], exports: [AuthFormComponent, ProtectedDirective] }); })();
1542
1638
 
1543
- /*
1544
- * Public API Surface of auth
1639
+ /*
1640
+ * Public API Surface of auth
1545
1641
  */
1546
1642
 
1547
- /**
1548
- * Generated bundle index. Do not edit.
1643
+ /**
1644
+ * Generated bundle index. Do not edit.
1549
1645
  */
1550
1646
 
1551
1647
  export { AdminGuard, AuthFormComponent, AuthGuard, AuthInterceptor, AuthRoutingModule, AuthService, AuthStorageService, IgoAuthModule, LoggedGuard, MSALAngularConfigFactory, MSALAngularConfigFactoryb2c, MSALConfigFactory, MSALConfigFactoryb2c, ProfilsGuard, ProtectedDirective, TokenService, provideAuthMicrosoft };