@cleavelandprice/ngx-lib 3.0.9 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/active-directory/model/ad-object-with-children.d.ts +4 -0
- package/active-directory/model/cleaveland-price-user.d.ts +17 -0
- package/active-directory/model/group.d.ts +7 -0
- package/active-directory/model/user.d.ts +0 -9
- package/active-directory/public_api.d.ts +3 -0
- package/active-directory/services/active-directory.service.d.ts +13 -0
- package/authentication/authentication.module.d.ts +3 -16
- package/authentication/model/abstract-authentication-service.d.ts +14 -0
- package/authentication/model/service-config.d.ts +1 -0
- package/authentication/object/authentication-object.module.d.ts +11 -0
- package/authentication/object/index.d.ts +5 -0
- package/authentication/object/model/default-config.d.ts +2 -0
- package/authentication/object/model/service-config.d.ts +3 -0
- package/authentication/object/public_api.d.ts +4 -0
- package/authentication/object/services/authentication-object.service.d.ts +23 -0
- package/authentication/public_api.d.ts +1 -6
- package/authentication/token/authentication-token.module.d.ts +11 -0
- package/authentication/token/gui/authentication-token-gui.module.d.ts +20 -0
- package/authentication/{components → token/gui/components}/login/login.component.d.ts +3 -3
- package/authentication/{components → token/gui/components}/login-form/login-form.component.d.ts +3 -3
- package/authentication/token/gui/index.d.ts +5 -0
- package/authentication/token/gui/model/default-config.d.ts +2 -0
- package/authentication/{model → token/gui/model}/login-form-data.d.ts +0 -0
- package/authentication/token/gui/model/service-config.d.ts +3 -0
- package/authentication/token/gui/public_api.d.ts +7 -0
- package/authentication/token/gui/services/authentication-token-gui.service.d.ts +15 -0
- package/authentication/token/index.d.ts +5 -0
- package/authentication/{model → token/model}/authentication-token.d.ts +0 -0
- package/authentication/token/model/default-config.d.ts +2 -0
- package/authentication/token/model/service-config.d.ts +4 -0
- package/authentication/token/public_api.d.ts +5 -0
- package/authentication/token/services/authentication-token.service.d.ts +22 -0
- package/esm2020/active-directory/active-directory.module.mjs +5 -5
- package/esm2020/active-directory/model/ad-object-with-children.mjs +2 -0
- package/esm2020/active-directory/model/cleaveland-price-user.mjs +2 -0
- package/esm2020/active-directory/model/default-config.mjs +2 -2
- package/esm2020/active-directory/model/group.mjs +2 -0
- package/esm2020/active-directory/model/user.mjs +1 -1
- package/esm2020/active-directory/public_api.mjs +4 -1
- package/esm2020/active-directory/services/active-directory.service.mjs +38 -10
- package/esm2020/authentication/authentication.module.mjs +10 -68
- package/esm2020/authentication/model/abstract-authentication-service.mjs +2 -0
- package/esm2020/authentication/model/service-config.mjs +1 -1
- package/esm2020/authentication/object/authentication-object.module.mjs +39 -0
- package/esm2020/authentication/object/cleavelandprice-ngx-lib-authentication-object.mjs +5 -0
- package/esm2020/authentication/object/model/default-config.mjs +5 -0
- package/esm2020/authentication/object/model/service-config.mjs +4 -0
- package/esm2020/authentication/object/public_api.mjs +5 -0
- package/esm2020/authentication/object/services/authentication-object.service.mjs +101 -0
- package/esm2020/authentication/public_api.mjs +2 -7
- package/esm2020/authentication/token/authentication-token.module.mjs +39 -0
- package/esm2020/authentication/token/cleavelandprice-ngx-lib-authentication-token.mjs +5 -0
- package/esm2020/authentication/token/gui/authentication-token-gui.module.mjs +77 -0
- package/esm2020/authentication/token/gui/cleavelandprice-ngx-lib-authentication-token-gui.mjs +5 -0
- package/esm2020/authentication/token/gui/components/login/login.component.mjs +39 -0
- package/esm2020/authentication/token/gui/components/login-form/login-form.component.mjs +60 -0
- package/esm2020/authentication/token/gui/model/default-config.mjs +6 -0
- package/esm2020/authentication/token/gui/model/login-form-data.mjs +2 -0
- package/esm2020/authentication/token/gui/model/service-config.mjs +4 -0
- package/esm2020/authentication/token/gui/public_api.mjs +8 -0
- package/esm2020/authentication/token/gui/services/authentication-token-gui.service.mjs +74 -0
- package/esm2020/authentication/token/model/authentication-token.mjs +2 -0
- package/esm2020/authentication/token/model/default-config.mjs +6 -0
- package/esm2020/authentication/token/model/service-config.mjs +4 -0
- package/esm2020/authentication/token/public_api.mjs +6 -0
- package/esm2020/authentication/token/services/authentication-token.service.mjs +112 -0
- package/esm2020/dialog/components/base/base.component.mjs +4 -4
- package/esm2020/dialog/components/choice/choice.component.mjs +4 -4
- package/esm2020/dialog/components/confirmation/confirmation.component.mjs +4 -4
- package/esm2020/dialog/components/input/input.component.mjs +4 -4
- package/esm2020/dialog/components/message/message.component.mjs +4 -4
- package/esm2020/dialog/dialog.module.mjs +4 -4
- package/esm2020/lib/ngx-lib.module.mjs +6 -6
- package/esm2020/lib/services/app-path-config.service.mjs +4 -4
- package/esm2020/public_api.mjs +2 -1
- package/esm2020/sharepoint/services/sharepoint.service.mjs +6 -8
- package/esm2020/sharepoint/sharepoint.module.mjs +11 -11
- package/esm2020/upload/components/upload/upload.component.mjs +5 -5
- package/esm2020/upload/components/upload-dialog/upload-dialog.component.mjs +5 -5
- package/esm2020/upload/services/upload.service.mjs +4 -4
- package/esm2020/upload/upload.module.mjs +7 -7
- package/esm2020/url-utilities/pipes/safe-resource-url.pipe.mjs +3 -3
- package/esm2020/url-utilities/pipes/safe-url.pipe.mjs +3 -3
- package/esm2020/url-utilities/pipes/uri-scheme.pipe.mjs +3 -3
- package/esm2020/url-utilities/url-utilities.module.mjs +4 -4
- package/fesm2015/cleavelandprice-ngx-lib-active-directory.mjs +41 -13
- package/fesm2015/cleavelandprice-ngx-lib-active-directory.mjs.map +1 -1
- package/fesm2015/cleavelandprice-ngx-lib-authentication-object.mjs +151 -0
- package/fesm2015/cleavelandprice-ngx-lib-authentication-object.mjs.map +1 -0
- package/fesm2015/cleavelandprice-ngx-lib-authentication-token-gui.mjs +251 -0
- package/fesm2015/cleavelandprice-ngx-lib-authentication-token-gui.mjs.map +1 -0
- package/fesm2015/cleavelandprice-ngx-lib-authentication-token.mjs +163 -0
- package/fesm2015/cleavelandprice-ngx-lib-authentication-token.mjs.map +1 -0
- package/fesm2015/cleavelandprice-ngx-lib-authentication.mjs +10 -282
- package/fesm2015/cleavelandprice-ngx-lib-authentication.mjs.map +1 -1
- package/fesm2015/cleavelandprice-ngx-lib-dialog.mjs +19 -19
- package/fesm2015/cleavelandprice-ngx-lib-dialog.mjs.map +1 -1
- package/fesm2015/cleavelandprice-ngx-lib-sharepoint.mjs +14 -16
- package/fesm2015/cleavelandprice-ngx-lib-sharepoint.mjs.map +1 -1
- package/fesm2015/cleavelandprice-ngx-lib-upload.mjs +15 -15
- package/fesm2015/cleavelandprice-ngx-lib-upload.mjs.map +1 -1
- package/fesm2015/cleavelandprice-ngx-lib-url-utilities.mjs +13 -13
- package/fesm2015/cleavelandprice-ngx-lib.mjs +11 -11
- package/fesm2015/cleavelandprice-ngx-lib.mjs.map +1 -1
- package/fesm2020/cleavelandprice-ngx-lib-active-directory.mjs +41 -13
- package/fesm2020/cleavelandprice-ngx-lib-active-directory.mjs.map +1 -1
- package/fesm2020/cleavelandprice-ngx-lib-authentication-object.mjs +150 -0
- package/fesm2020/cleavelandprice-ngx-lib-authentication-object.mjs.map +1 -0
- package/fesm2020/cleavelandprice-ngx-lib-authentication-token-gui.mjs +246 -0
- package/fesm2020/cleavelandprice-ngx-lib-authentication-token-gui.mjs.map +1 -0
- package/fesm2020/cleavelandprice-ngx-lib-authentication-token.mjs +162 -0
- package/fesm2020/cleavelandprice-ngx-lib-authentication-token.mjs.map +1 -0
- package/fesm2020/cleavelandprice-ngx-lib-authentication.mjs +10 -277
- package/fesm2020/cleavelandprice-ngx-lib-authentication.mjs.map +1 -1
- package/fesm2020/cleavelandprice-ngx-lib-dialog.mjs +19 -19
- package/fesm2020/cleavelandprice-ngx-lib-dialog.mjs.map +1 -1
- package/fesm2020/cleavelandprice-ngx-lib-sharepoint.mjs +14 -16
- package/fesm2020/cleavelandprice-ngx-lib-sharepoint.mjs.map +1 -1
- package/fesm2020/cleavelandprice-ngx-lib-upload.mjs +15 -15
- package/fesm2020/cleavelandprice-ngx-lib-upload.mjs.map +1 -1
- package/fesm2020/cleavelandprice-ngx-lib-url-utilities.mjs +13 -13
- package/fesm2020/cleavelandprice-ngx-lib.mjs +11 -11
- package/fesm2020/cleavelandprice-ngx-lib.mjs.map +1 -1
- package/package.json +28 -3
- package/public_api.d.ts +1 -0
- package/sharepoint/services/sharepoint.service.d.ts +3 -3
- package/sharepoint/sharepoint.module.d.ts +6 -6
- package/upload/components/upload/upload.component.d.ts +1 -1
- package/upload/components/upload-dialog/upload-dialog.component.d.ts +1 -1
- package/upload/services/upload.service.d.ts +2 -2
- package/authentication/model/default-config.d.ts +0 -2
- package/authentication/services/authentication.service.d.ts +0 -25
- package/esm2020/authentication/components/login/login.component.mjs +0 -39
- package/esm2020/authentication/components/login-form/login-form.component.mjs +0 -60
- package/esm2020/authentication/model/authentication-token.mjs +0 -2
- package/esm2020/authentication/model/default-config.mjs +0 -4
- package/esm2020/authentication/model/login-form-data.mjs +0 -2
- package/esm2020/authentication/services/authentication.service.mjs +0 -126
|
@@ -6,14 +6,14 @@ import { UriSchemePipe } from './pipes/uri-scheme.pipe';
|
|
|
6
6
|
import * as i0 from "@angular/core";
|
|
7
7
|
export class UrlUtilitiesModule {
|
|
8
8
|
}
|
|
9
|
-
UrlUtilitiesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
10
|
-
UrlUtilitiesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.
|
|
9
|
+
UrlUtilitiesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: UrlUtilitiesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
10
|
+
UrlUtilitiesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.1", ngImport: i0, type: UrlUtilitiesModule, declarations: [SafeResourceUrlPipe,
|
|
11
11
|
SafeUrlPipe,
|
|
12
12
|
UriSchemePipe], imports: [CommonModule], exports: [SafeResourceUrlPipe,
|
|
13
13
|
SafeUrlPipe,
|
|
14
14
|
UriSchemePipe] });
|
|
15
|
-
UrlUtilitiesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.
|
|
16
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.
|
|
15
|
+
UrlUtilitiesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: UrlUtilitiesModule, imports: [CommonModule] });
|
|
16
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: UrlUtilitiesModule, decorators: [{
|
|
17
17
|
type: NgModule,
|
|
18
18
|
args: [{
|
|
19
19
|
declarations: [
|
|
@@ -18,7 +18,7 @@ const defaultLoggingConfig = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const defaultConfig = {
|
|
21
|
-
apiUrl: 'http://utilityapi
|
|
21
|
+
apiUrl: 'http://utilityapi',
|
|
22
22
|
caching: defaultCachingConfig,
|
|
23
23
|
logging: defaultLoggingConfig
|
|
24
24
|
};
|
|
@@ -26,8 +26,6 @@ const defaultConfig = {
|
|
|
26
26
|
class ServiceConfig {
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
//#region Imports
|
|
30
|
-
//#endregion
|
|
31
29
|
class ActiveDirectoryService {
|
|
32
30
|
//#endregion
|
|
33
31
|
//#region Initialization
|
|
@@ -53,12 +51,12 @@ class ActiveDirectoryService {
|
|
|
53
51
|
return moment().isAfter(expiration);
|
|
54
52
|
}
|
|
55
53
|
//#endregion
|
|
56
|
-
getUsers(includePhoto = false, includeDisabled = false, parentOU) {
|
|
54
|
+
getUsers(includePhoto = false, includeDisabled = false, parentOU = '') {
|
|
57
55
|
var _a, _b, _c;
|
|
58
56
|
// If caching is enabled, there will be two calls to the API if the cache is null/expired
|
|
59
57
|
// One call is to update the cache and the other is to return the data that the user requested
|
|
60
58
|
// Subsequent calls will bypass the API and returned cached data until it expires
|
|
61
|
-
const observable$ = this.http.get(`${this.config.apiUrl}/${includePhoto}/${includeDisabled}/${parentOU
|
|
59
|
+
const observable$ = this.http.get(`${this.config.apiUrl}/users/${includePhoto}/${includeDisabled}/${parentOU}`);
|
|
62
60
|
if ((_a = this.config.caching) === null || _a === void 0 ? void 0 : _a.enabled) {
|
|
63
61
|
if (this.cacheExpired) {
|
|
64
62
|
// Get the data and cache it
|
|
@@ -89,7 +87,7 @@ class ActiveDirectoryService {
|
|
|
89
87
|
return observable$;
|
|
90
88
|
}
|
|
91
89
|
getUser(accountName, includePhoto = false) {
|
|
92
|
-
return this.http.get(`${this.config.apiUrl}/name/${accountName}/${includePhoto}`);
|
|
90
|
+
return this.http.get(`${this.config.apiUrl}/users/name/${accountName}/${includePhoto}`);
|
|
93
91
|
}
|
|
94
92
|
clearCache() {
|
|
95
93
|
var _a;
|
|
@@ -98,10 +96,40 @@ class ActiveDirectoryService {
|
|
|
98
96
|
console.log('Cache cleared');
|
|
99
97
|
}
|
|
100
98
|
}
|
|
99
|
+
getDomains() {
|
|
100
|
+
return this.http.get(`${this.config.apiUrl}/activedirectory/domains`);
|
|
101
|
+
}
|
|
102
|
+
getOUs(parentOU = '') {
|
|
103
|
+
return this.http.get(`${this.config.apiUrl}/activedirectory/ous/${parentOU}`);
|
|
104
|
+
}
|
|
105
|
+
getContainers(parentOU = '') {
|
|
106
|
+
return this.http.get(`${this.config.apiUrl}/activedirectory/containers/${parentOU}`);
|
|
107
|
+
}
|
|
108
|
+
getGroups(parentOU = '') {
|
|
109
|
+
return this.http.get(`${this.config.apiUrl}/activedirectory/groups/${parentOU}`);
|
|
110
|
+
}
|
|
111
|
+
getDistinctUserAttributeValues(attributeName) {
|
|
112
|
+
return this.http.get(`${this.config.apiUrl}/activedirectory/distinct/${attributeName}`);
|
|
113
|
+
}
|
|
114
|
+
getDepartments() {
|
|
115
|
+
return this.http.get(`${this.config.apiUrl}/activedirectory/departments`);
|
|
116
|
+
}
|
|
117
|
+
getTitles() {
|
|
118
|
+
return this.http.get(`${this.config.apiUrl}/activedirectory/titles`);
|
|
119
|
+
}
|
|
120
|
+
getComputers(includeDisabled = false, parentOU = '') {
|
|
121
|
+
return this.http.get(`${this.config.apiUrl}/activedirectory/computers/${includeDisabled}/${parentOU}`);
|
|
122
|
+
}
|
|
123
|
+
getServers(includeDisabled = false, parentOU = '') {
|
|
124
|
+
return this.http.get(`${this.config.apiUrl}/activedirectory/servers/${includeDisabled}/${parentOU}`);
|
|
125
|
+
}
|
|
126
|
+
getWorkstations(includeDisabled = false, parentOU = '') {
|
|
127
|
+
return this.http.get(`${this.config.apiUrl}/activedirectory/workstations/${includeDisabled}/${parentOU}`);
|
|
128
|
+
}
|
|
101
129
|
}
|
|
102
|
-
ActiveDirectoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
103
|
-
ActiveDirectoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.
|
|
104
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.
|
|
130
|
+
ActiveDirectoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: ActiveDirectoryService, deps: [{ token: ServiceConfig, optional: true }, { token: i2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
131
|
+
ActiveDirectoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: ActiveDirectoryService, providedIn: 'root' });
|
|
132
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: ActiveDirectoryService, decorators: [{
|
|
105
133
|
type: Injectable,
|
|
106
134
|
args: [{
|
|
107
135
|
providedIn: 'root'
|
|
@@ -128,10 +156,10 @@ class ActiveDirectoryModule {
|
|
|
128
156
|
};
|
|
129
157
|
}
|
|
130
158
|
}
|
|
131
|
-
ActiveDirectoryModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
132
|
-
ActiveDirectoryModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.
|
|
133
|
-
ActiveDirectoryModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.
|
|
134
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.
|
|
159
|
+
ActiveDirectoryModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: ActiveDirectoryModule, deps: [{ token: ActiveDirectoryModule, optional: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.NgModule });
|
|
160
|
+
ActiveDirectoryModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.1", ngImport: i0, type: ActiveDirectoryModule, imports: [CommonModule] });
|
|
161
|
+
ActiveDirectoryModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: ActiveDirectoryModule, imports: [CommonModule] });
|
|
162
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: ActiveDirectoryModule, decorators: [{
|
|
135
163
|
type: NgModule,
|
|
136
164
|
args: [{
|
|
137
165
|
declarations: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleavelandprice-ngx-lib-active-directory.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/active-directory/src/model/default-caching-config.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/model/default-logging-config.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/model/default-config.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/model/service-config.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/services/active-directory.service.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/active-directory.module.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/cleavelandprice-ngx-lib-active-directory.ts"],"sourcesContent":["import { CachingConfig } from \"./caching-config\";\r\n\r\nexport const defaultCachingConfig: CachingConfig = {\r\n enabled: false,\r\n lifeMinutes: 720\r\n}","import { LoggingConfig } from \"./logging-config\";\r\n\r\nexport const defaultLoggingConfig: LoggingConfig = {\r\n dataCached: false,\r\n cachedDataReturned: false,\r\n freshDataReturned: false,\r\n cacheCleared: false\r\n}","import { ServiceConfig } from \"./service-config\";\r\nimport { defaultCachingConfig } from './default-caching-config';\r\nimport { defaultLoggingConfig } from \"./default-logging-config\";\r\n\r\nexport const defaultConfig: ServiceConfig = {\r\n apiUrl: 'http://utilityapi/users',\r\n caching: defaultCachingConfig,\r\n logging: defaultLoggingConfig\r\n}","import { CachingConfig } from './caching-config';\r\nimport { LoggingConfig } from './logging-config';\r\n\r\nexport class ServiceConfig {\r\n apiUrl!: string;\r\n caching?: CachingConfig;\r\n logging?: LoggingConfig;\r\n}\r\n","//#region Imports\nimport { Injectable, Optional } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { Observable, of } from 'rxjs';\n\nimport { defaultConfig } from '../model/default-config';\nimport { defaultCachingConfig } from '../model/default-caching-config';\nimport { defaultLoggingConfig } from '../model/default-logging-config';\n\nimport { CacheObject } from '../model/cache-object';\nimport { ServiceConfig } from '../model/service-config';\nimport { User } from '../model/user';\n\nimport moment from 'moment';\n//#endregion\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ActiveDirectoryService {\n private cache: CacheObject<User> | null = null;\n private defaultCacheLifeMinutes = 720;\n\n //#region Properties\n private get cacheExpired(): boolean {\n if (!this.cache) {\n return true;\n }\n\n const lifeMinutes = this.config.caching?.lifeMinutes ?? this.defaultCacheLifeMinutes;\n const expiration = moment(this.cache.lastUpdate)\n .add(lifeMinutes, 'minutes');\n\n return moment().isAfter(expiration);\n }\n //#endregion\n\n //#region Initialization\n // If a ServiceConfig object is not provided when the module is imported, then default values are pulled in from default-config.ts.\n constructor(@Optional() private config: ServiceConfig,\n private http: HttpClient) {\n\n this.config = {\n ...defaultConfig,\n ...this.config\n };\n\n this.config.caching = {\n ...defaultCachingConfig,\n ...this.config.caching\n };\n\n this.config.logging = {\n ...defaultLoggingConfig,\n ...this.config.logging\n };\n }\n //#endregion\n\n getUsers(includePhoto = false, includeDisabled = false, parentOU?: string): Observable<User[]> {\n // If caching is enabled, there will be two calls to the API if the cache is null/expired\n // One call is to update the cache and the other is to return the data that the user requested\n // Subsequent calls will bypass the API and returned cached data until it expires\n\n const observable$ = this.http.get<User[]>(`${this.config.apiUrl}/${includePhoto}/${includeDisabled}/${parentOU ?? ''}`);\n\n if (this.config.caching?.enabled) {\n if (this.cacheExpired) {\n // Get the data and cache it\n observable$.subscribe(data => {\n this.cache = {\n data,\n lastUpdate: moment()\n };\n\n if (this.config.logging?.dataCached) {\n const lifeMinutes = this.config.caching?.lifeMinutes ?? this.defaultCacheLifeMinutes;\n console.log(`Data cached for ${lifeMinutes} minutes`);\n }\n });\n } else {\n // Cache exists and hasn't expired yet\n if (this.config.logging?.cachedDataReturned) {\n console.log('Returning cached users');\n }\n\n return of(this.cache!.data);\n }\n }\n\n // Cache is either disabled or expired, return data from API\n if (this.config.logging?.freshDataReturned) {\n console.log('Returning fresh users');\n }\n\n return observable$;\n }\n\n getUser(accountName: string, includePhoto = false): Observable<User> {\n return this.http.get<User>(`${this.config.apiUrl}/name/${accountName}/${includePhoto}`);\n }\n\n clearCache(): void {\n this.cache = null;\n\n if (this.config.logging?.cacheCleared) {\n console.log('Cache cleared');\n }\n }\n}\n","import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { ServiceConfig } from './model/service-config';\nimport { ActiveDirectoryService } from './services/active-directory.service';\n\n@NgModule({\n declarations: [],\n imports: [\n CommonModule\n ]\n})\nexport class ActiveDirectoryModule {\n static forRoot(config: ServiceConfig): ModuleWithProviders<ActiveDirectoryModule> {\n return {\n ngModule: ActiveDirectoryModule,\n providers: [\n ActiveDirectoryService,\n { provide: ServiceConfig, useValue: config }\n ]\n };\n }\n\n constructor( @Optional() @SkipSelf() parentModule: ActiveDirectoryModule) {\n if (parentModule) {\n throw new Error(\n 'ActiveDirectoryModule is already loaded. Import it in the AppModule only');\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["i1.ServiceConfig"],"mappings":";;;;;;;AAEa,MAAA,oBAAoB,GAAkB;AAC/C,IAAA,OAAO,EAAE,KAAK;AACd,IAAA,WAAW,EAAE,GAAG;;;ACFP,MAAA,oBAAoB,GAAkB;AAC/C,IAAA,UAAU,EAAE,KAAK;AACjB,IAAA,kBAAkB,EAAE,KAAK;AACzB,IAAA,iBAAiB,EAAE,KAAK;AACxB,IAAA,YAAY,EAAE,KAAK;;;ACFV,MAAA,aAAa,GAAkB;AACxC,IAAA,MAAM,EAAE,yBAAyB;AACjC,IAAA,OAAO,EAAE,oBAAoB;AAC7B,IAAA,OAAO,EAAE,oBAAoB;;;MCJpB,aAAa,CAAA;AAIzB;;ACPD;AAcA;MAKa,sBAAsB,CAAA;;;;IAoBjC,WAAgC,CAAA,MAAqB,EACjC,IAAgB,EAAA;AADJ,QAAA,IAAM,CAAA,MAAA,GAAN,MAAM,CAAe;AACjC,QAAA,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAY;AApB5B,QAAA,IAAK,CAAA,KAAA,GAA6B,IAAI,CAAC;AACvC,QAAA,IAAuB,CAAA,uBAAA,GAAG,GAAG,CAAC;QAqBxB,IAAI,CAAC,MAAM,GACN,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,aAAa,GACb,IAAI,CAAC,MAAM,CACf,CAAC;AAEF,QAAA,IAAI,CAAC,MAAM,CAAC,OAAO,GACd,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,oBAAoB,CACpB,EAAA,IAAI,CAAC,MAAM,CAAC,OAAO,CACvB,CAAC;AAEF,QAAA,IAAI,CAAC,MAAM,CAA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,YAAA,QAAQ,EAAE,qBAAqB;AAC/B,YAAA,SAAS,EAAE;gBACT,sBAAsB;AACtB,gBAAA,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE;AAC7C,aAAA;SACF,CAAC;KACH;;AATU,qBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,kBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,kBAWmB,qBAAqB,EAAA,QAAA,EAAA,IAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAX7D,qBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,YAH9B,YAAY,CAAA,EAAA,CAAA,CAAA;AAGH,qBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,YAH9B,YAAY,CAAA,EAAA,CAAA,CAAA;2FAGH,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBANjC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;iBACF,CAAA;;wBAYoD,qBAAqB,EAAA,UAAA,EAAA,CAAA;8BAA1D,QAAQ;;8BAAI,QAAQ;;;;ACtBpC;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"cleavelandprice-ngx-lib-active-directory.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/active-directory/src/model/default-caching-config.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/model/default-logging-config.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/model/default-config.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/model/service-config.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/services/active-directory.service.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/active-directory.module.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/cleavelandprice-ngx-lib-active-directory.ts"],"sourcesContent":["import { CachingConfig } from \"./caching-config\";\r\n\r\nexport const defaultCachingConfig: CachingConfig = {\r\n enabled: false,\r\n lifeMinutes: 720\r\n}","import { LoggingConfig } from \"./logging-config\";\r\n\r\nexport const defaultLoggingConfig: LoggingConfig = {\r\n dataCached: false,\r\n cachedDataReturned: false,\r\n freshDataReturned: false,\r\n cacheCleared: false\r\n}","import { ServiceConfig } from \"./service-config\";\r\nimport { defaultCachingConfig } from './default-caching-config';\r\nimport { defaultLoggingConfig } from \"./default-logging-config\";\r\n\r\nexport const defaultConfig: ServiceConfig = {\r\n apiUrl: 'http://utilityapi',\r\n caching: defaultCachingConfig,\r\n logging: defaultLoggingConfig\r\n}","import { CachingConfig } from './caching-config';\r\nimport { LoggingConfig } from './logging-config';\r\n\r\nexport class ServiceConfig {\r\n apiUrl!: string;\r\n caching?: CachingConfig;\r\n logging?: LoggingConfig;\r\n}\r\n","import { Injectable, Optional } from '@angular/core';\r\nimport { HttpClient } from '@angular/common/http';\r\nimport { Observable, of } from 'rxjs';\r\nimport moment from 'moment';\r\n\r\nimport { defaultConfig } from '../model/default-config';\r\nimport { defaultCachingConfig } from '../model/default-caching-config';\r\nimport { defaultLoggingConfig } from '../model/default-logging-config';\r\n\r\nimport { ADObject } from '../model/ad-object';\r\nimport { ADObjectWithChildren } from '../model/ad-object-with-children';\r\nimport { CacheObject } from '../model/cache-object';\r\nimport { Group } from '../model/group';\r\nimport { ServiceConfig } from '../model/service-config';\r\nimport { User } from '../model/user';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class ActiveDirectoryService {\r\n private cache: CacheObject<User> | null = null;\r\n private defaultCacheLifeMinutes = 720;\r\n\r\n //#region Properties\r\n private get cacheExpired(): boolean {\r\n if (!this.cache) {\r\n return true;\r\n }\r\n\r\n const lifeMinutes = this.config.caching?.lifeMinutes ?? this.defaultCacheLifeMinutes;\r\n const expiration = moment(this.cache.lastUpdate)\r\n .add(lifeMinutes, 'minutes');\r\n\r\n return moment().isAfter(expiration);\r\n }\r\n //#endregion\r\n\r\n //#region Initialization\r\n // If a ServiceConfig object is not provided when the module is imported, then default values are pulled in from default-config.ts.\r\n constructor(@Optional() private config: ServiceConfig,\r\n private http: HttpClient) {\r\n\r\n this.config = {\r\n ...defaultConfig,\r\n ...this.config\r\n };\r\n\r\n this.config.caching = {\r\n ...defaultCachingConfig,\r\n ...this.config.caching\r\n };\r\n\r\n this.config.logging = {\r\n ...defaultLoggingConfig,\r\n ...this.config.logging\r\n };\r\n }\r\n //#endregion\r\n\r\n getUsers(includePhoto = false, includeDisabled = false, parentOU = ''): Observable<User[]> {\r\n // If caching is enabled, there will be two calls to the API if the cache is null/expired\r\n // One call is to update the cache and the other is to return the data that the user requested\r\n // Subsequent calls will bypass the API and returned cached data until it expires\r\n\r\n const observable$ = this.http.get<User[]>(`${this.config.apiUrl}/users/${includePhoto}/${includeDisabled}/${parentOU}`);\r\n\r\n if (this.config.caching?.enabled) {\r\n if (this.cacheExpired) {\r\n // Get the data and cache it\r\n observable$.subscribe(data => {\r\n this.cache = {\r\n data,\r\n lastUpdate: moment()\r\n };\r\n\r\n if (this.config.logging?.dataCached) {\r\n const lifeMinutes = this.config.caching?.lifeMinutes ?? this.defaultCacheLifeMinutes;\r\n console.log(`Data cached for ${lifeMinutes} minutes`);\r\n }\r\n });\r\n } else {\r\n // Cache exists and hasn't expired yet\r\n if (this.config.logging?.cachedDataReturned) {\r\n console.log('Returning cached users');\r\n }\r\n\r\n return of(this.cache!.data);\r\n }\r\n }\r\n\r\n // Cache is either disabled or expired, return data from API\r\n if (this.config.logging?.freshDataReturned) {\r\n console.log('Returning fresh users');\r\n }\r\n\r\n return observable$;\r\n }\r\n\r\n getUser(accountName: string, includePhoto = false): Observable<User> {\r\n return this.http.get<User>(`${this.config.apiUrl}/users/name/${accountName}/${includePhoto}`);\r\n }\r\n\r\n clearCache(): void {\r\n this.cache = null;\r\n\r\n if (this.config.logging?.cacheCleared) {\r\n console.log('Cache cleared');\r\n }\r\n }\r\n\r\n getDomains(): Observable<ADObject[]> {\r\n return this.http.get<ADObject[]>(`${this.config.apiUrl}/activedirectory/domains`);\r\n }\r\n\r\n getOUs(parentOU = ''): Observable<ADObjectWithChildren[]> {\r\n return this.http.get<ADObjectWithChildren[]>(`${this.config.apiUrl}/activedirectory/ous/${parentOU}`);\r\n }\r\n\r\n getContainers(parentOU = ''): Observable<ADObjectWithChildren[]> {\r\n return this.http.get<ADObjectWithChildren[]>(`${this.config.apiUrl}/activedirectory/containers/${parentOU}`);\r\n }\r\n\r\n getGroups(parentOU = ''): Observable<Group[]> {\r\n return this.http.get<Group[]>(`${this.config.apiUrl}/activedirectory/groups/${parentOU}`);\r\n }\r\n\r\n getDistinctUserAttributeValues(attributeName: string) : Observable<any[]> {\r\n return this.http.get<any[]>(`${this.config.apiUrl}/activedirectory/distinct/${attributeName}`);\r\n }\r\n\r\n getDepartments() : Observable<string[]> {\r\n return this.http.get<string[]>(`${this.config.apiUrl}/activedirectory/departments`);\r\n }\r\n\r\n getTitles() : Observable<string[]> {\r\n return this.http.get<string[]>(`${this.config.apiUrl}/activedirectory/titles`);\r\n }\r\n\r\n getComputers(includeDisabled = false, parentOU = ''): Observable<User[]> {\r\n return this.http.get<User[]>(`${this.config.apiUrl}/activedirectory/computers/${includeDisabled}/${parentOU}`);\r\n }\r\n\r\n getServers(includeDisabled = false, parentOU = ''): Observable<User[]> {\r\n return this.http.get<User[]>(`${this.config.apiUrl}/activedirectory/servers/${includeDisabled}/${parentOU}`);\r\n }\r\n\r\n getWorkstations(includeDisabled = false, parentOU = ''): Observable<User[]> {\r\n return this.http.get<User[]>(`${this.config.apiUrl}/activedirectory/workstations/${includeDisabled}/${parentOU}`);\r\n }\r\n}\r\n","import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\n\r\nimport { ServiceConfig } from './model/service-config';\r\n\r\nimport { ActiveDirectoryService } from './services/active-directory.service';\r\n\r\n@NgModule({\r\n declarations: [],\r\n imports: [\r\n CommonModule\r\n ]\r\n})\r\nexport class ActiveDirectoryModule {\r\n static forRoot(config: ServiceConfig): ModuleWithProviders<ActiveDirectoryModule> {\r\n return {\r\n ngModule: ActiveDirectoryModule,\r\n providers: [\r\n ActiveDirectoryService,\r\n { provide: ServiceConfig, useValue: config }\r\n ]\r\n };\r\n }\r\n\r\n constructor(@Optional() @SkipSelf() parentModule: ActiveDirectoryModule) {\r\n if (parentModule) {\r\n throw new Error(\r\n 'ActiveDirectoryModule is already loaded. Import it in the AppModule only');\r\n }\r\n }\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["i1.ServiceConfig"],"mappings":";;;;;;;AAEa,MAAA,oBAAoB,GAAkB;AAC/C,IAAA,OAAO,EAAE,KAAK;AACd,IAAA,WAAW,EAAE,GAAG;;;ACFP,MAAA,oBAAoB,GAAkB;AAC/C,IAAA,UAAU,EAAE,KAAK;AACjB,IAAA,kBAAkB,EAAE,KAAK;AACzB,IAAA,iBAAiB,EAAE,KAAK;AACxB,IAAA,YAAY,EAAE,KAAK;;;ACFV,MAAA,aAAa,GAAkB;AACxC,IAAA,MAAM,EAAE,mBAAmB;AAC3B,IAAA,OAAO,EAAE,oBAAoB;AAC7B,IAAA,OAAO,EAAE,oBAAoB;;;MCJpB,aAAa,CAAA;AAIzB;;MCYY,sBAAsB,CAAA;;;;IAoBjC,WAAgC,CAAA,MAAqB,EACjC,IAAgB,EAAA;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;AACtB,gBAAA,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE;AAC7C,aAAA;SACF,CAAC;KACH;;kHATU,qBAAqB,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,qBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAArB,qBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,YAH9B,YAAY,CAAA,EAAA,CAAA,CAAA;AAGH,qBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,YAH9B,YAAY,CAAA,EAAA,CAAA,CAAA;2FAGH,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBANjC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;iBACF,CAAA;;;8BAYc,QAAQ;;8BAAI,QAAQ;;;;ACxBnC;;AAEG;;;;"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { ServiceConfig as ServiceConfig$1 } from '@cleavelandprice/ngx-lib/authentication';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { EventEmitter, Injectable, Optional, Output, NgModule, SkipSelf } from '@angular/core';
|
|
4
|
+
import * as i2 from '@angular/common/http';
|
|
5
|
+
import { CommonModule } from '@angular/common';
|
|
6
|
+
|
|
7
|
+
const defaultConfig = {
|
|
8
|
+
apiUrl: 'http://utilityapi/authenticate',
|
|
9
|
+
tokenName: 'user'
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
class ServiceConfig extends ServiceConfig$1 {
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
class AuthenticationObjectService {
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region Lifecycle
|
|
18
|
+
// If a ServiceConfig object is not provided when the module is imported, then default values are pulled in from default-config.ts.
|
|
19
|
+
constructor(config, http) {
|
|
20
|
+
this.config = config;
|
|
21
|
+
this.http = http;
|
|
22
|
+
//#region Fields
|
|
23
|
+
this.authenticatedChanged = new EventEmitter();
|
|
24
|
+
this.authenticatingChanged = new EventEmitter();
|
|
25
|
+
this.authenticationError = new EventEmitter();
|
|
26
|
+
this.authenticating = false; // Flag set to true while the service is attempting to authenticate the user
|
|
27
|
+
this.authenticated = false; // Flag set to true when the user is successfully authenticated
|
|
28
|
+
this.authenticatedUser = null; // Object representing the authenticated user
|
|
29
|
+
this.config = Object.assign(Object.assign({}, defaultConfig), this.config);
|
|
30
|
+
this.checkForExistingToken();
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region Utilities
|
|
34
|
+
//Authenticate the user and store the token in Local Storage
|
|
35
|
+
login(username, password, adminGroup) {
|
|
36
|
+
const request = {
|
|
37
|
+
username: username,
|
|
38
|
+
password: password,
|
|
39
|
+
adminGroup: adminGroup
|
|
40
|
+
};
|
|
41
|
+
this.authenticating = true;
|
|
42
|
+
this.authenticatingChanged.emit(this.authenticating);
|
|
43
|
+
this.http.post(this.config.apiUrl, request)
|
|
44
|
+
.subscribe({
|
|
45
|
+
next: (user) => {
|
|
46
|
+
if (user) {
|
|
47
|
+
this.validateUser(user);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.logout();
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
error: (err) => {
|
|
54
|
+
this.authenticating = false;
|
|
55
|
+
this.authenticatingChanged.emit(this.authenticating);
|
|
56
|
+
this.authenticationError.emit(err);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//Logout the user and delete the token from Local Storage
|
|
61
|
+
logout() {
|
|
62
|
+
if (localStorage.getItem(this.config.tokenName)) {
|
|
63
|
+
localStorage.removeItem(this.config.tokenName);
|
|
64
|
+
}
|
|
65
|
+
this.authenticatedUser = null;
|
|
66
|
+
this.authenticated = false;
|
|
67
|
+
this.authenticatedChanged.emit(false);
|
|
68
|
+
}
|
|
69
|
+
validateUser(token) {
|
|
70
|
+
this.authenticatedUser = {
|
|
71
|
+
admin: false,
|
|
72
|
+
displayName: token.displayName,
|
|
73
|
+
accountName: token.sAMAccountName,
|
|
74
|
+
distinguishedName: token.distinguishedName,
|
|
75
|
+
employeeNumber: token.employeeNumber,
|
|
76
|
+
memberOf: token.memberOf.join(',')
|
|
77
|
+
};
|
|
78
|
+
localStorage.setItem(this.config.tokenName, JSON.stringify(token));
|
|
79
|
+
this.authenticated = true;
|
|
80
|
+
this.authenticatedChanged.emit(this.authenticated);
|
|
81
|
+
this.authenticating = false;
|
|
82
|
+
this.authenticatingChanged.emit(this.authenticating);
|
|
83
|
+
}
|
|
84
|
+
checkForExistingToken() {
|
|
85
|
+
const token = localStorage.getItem(this.config.tokenName);
|
|
86
|
+
if (token) {
|
|
87
|
+
this.validateUser(JSON.parse(token));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
AuthenticationObjectService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: AuthenticationObjectService, deps: [{ token: ServiceConfig, optional: true }, { token: i2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
92
|
+
AuthenticationObjectService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: AuthenticationObjectService, providedIn: 'root' });
|
|
93
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: AuthenticationObjectService, decorators: [{
|
|
94
|
+
type: Injectable,
|
|
95
|
+
args: [{
|
|
96
|
+
providedIn: 'root'
|
|
97
|
+
}]
|
|
98
|
+
}], ctorParameters: function () {
|
|
99
|
+
return [{ type: ServiceConfig, decorators: [{
|
|
100
|
+
type: Optional
|
|
101
|
+
}] }, { type: i2.HttpClient }];
|
|
102
|
+
}, propDecorators: { authenticatedChanged: [{
|
|
103
|
+
type: Output
|
|
104
|
+
}], authenticatingChanged: [{
|
|
105
|
+
type: Output
|
|
106
|
+
}], authenticationError: [{
|
|
107
|
+
type: Output
|
|
108
|
+
}] } });
|
|
109
|
+
|
|
110
|
+
class AuthenticationObjectModule {
|
|
111
|
+
constructor(parentModule) {
|
|
112
|
+
if (parentModule) {
|
|
113
|
+
throw new Error('AuthenticationObjectModule is already loaded. Import it in the AppModule only');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
static forRoot(config) {
|
|
117
|
+
return {
|
|
118
|
+
ngModule: AuthenticationObjectModule,
|
|
119
|
+
providers: [
|
|
120
|
+
AuthenticationObjectService,
|
|
121
|
+
{ provide: ServiceConfig, useValue: config }
|
|
122
|
+
]
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
AuthenticationObjectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: AuthenticationObjectModule, deps: [{ token: AuthenticationObjectModule, optional: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.NgModule });
|
|
127
|
+
AuthenticationObjectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.1", ngImport: i0, type: AuthenticationObjectModule, imports: [CommonModule] });
|
|
128
|
+
AuthenticationObjectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: AuthenticationObjectModule, imports: [CommonModule] });
|
|
129
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: AuthenticationObjectModule, decorators: [{
|
|
130
|
+
type: NgModule,
|
|
131
|
+
args: [{
|
|
132
|
+
declarations: [],
|
|
133
|
+
imports: [
|
|
134
|
+
CommonModule
|
|
135
|
+
],
|
|
136
|
+
exports: []
|
|
137
|
+
}]
|
|
138
|
+
}], ctorParameters: function () {
|
|
139
|
+
return [{ type: AuthenticationObjectModule, decorators: [{
|
|
140
|
+
type: Optional
|
|
141
|
+
}, {
|
|
142
|
+
type: SkipSelf
|
|
143
|
+
}] }];
|
|
144
|
+
} });
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Generated bundle index. Do not edit.
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
export { AuthenticationObjectModule, AuthenticationObjectService, ServiceConfig, defaultConfig };
|
|
151
|
+
//# sourceMappingURL=cleavelandprice-ngx-lib-authentication-object.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleavelandprice-ngx-lib-authentication-object.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/authentication/object/src/model/default-config.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/object/src/model/service-config.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/object/src/services/authentication-object.service.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/object/src/authentication-object.module.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/object/src/cleavelandprice-ngx-lib-authentication-object.ts"],"sourcesContent":["import { ServiceConfig } from './service-config';\r\n\r\nexport const defaultConfig: ServiceConfig = {\r\n apiUrl: 'http://utilityapi/authenticate',\r\n tokenName: 'user'\r\n}","import { ServiceConfig as BaseServiceConfig } from '@cleavelandprice/ngx-lib/authentication';\r\n\r\nexport class ServiceConfig extends BaseServiceConfig {\r\n}","import { EventEmitter, Injectable, Optional, Output } from '@angular/core';\r\nimport { HttpClient } from '@angular/common/http';\r\n\r\nimport { User } from '@cleavelandprice/ngx-lib/active-directory';\r\n\r\nimport {\r\n AbstractAuthenticationService,\r\n AuthenticatedUser,\r\n AuthenticationRequest\r\n} from '@cleavelandprice/ngx-lib/authentication';\r\n\r\nimport { defaultConfig } from '../model/default-config';\r\nimport { ServiceConfig } from '../model/service-config';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class AuthenticationObjectService implements AbstractAuthenticationService {\r\n //#region Fields\r\n @Output() authenticatedChanged = new EventEmitter<boolean>();\r\n @Output() authenticatingChanged = new EventEmitter<boolean>();\r\n @Output() authenticationError = new EventEmitter();\r\n authenticating = false; // Flag set to true while the service is attempting to authenticate the user\r\n authenticated = false; // Flag set to true when the user is successfully authenticated\r\n authenticatedUser: AuthenticatedUser | null = null; // Object representing the authenticated user\r\n //#endregion\r\n\r\n //#region Lifecycle\r\n // If a ServiceConfig object is not provided when the module is imported, then default values are pulled in from default-config.ts.\r\n constructor(@Optional() private config: ServiceConfig,\r\n private http: HttpClient) {\r\n\r\n this.config = {\r\n ...defaultConfig,\r\n ...this.config\r\n };\r\n\r\n this.checkForExistingToken();\r\n }\r\n //#endregion\r\n\r\n //#region Utilities\r\n //Authenticate the user and store the token in Local Storage\r\n login(username: string, password: string, adminGroup?: string): void {\r\n const request: AuthenticationRequest = {\r\n username: username,\r\n password: password,\r\n adminGroup: adminGroup\r\n };\r\n\r\n this.authenticating = true;\r\n this.authenticatingChanged.emit(this.authenticating);\r\n\r\n this.http.post(this.config.apiUrl, request)\r\n .subscribe({\r\n next: (user) => {\r\n if (user) {\r\n this.validateUser(user as User);\r\n } else {\r\n this.logout();\r\n }\r\n },\r\n error: (err) => {\r\n this.authenticating = false;\r\n this.authenticatingChanged.emit(this.authenticating);\r\n this.authenticationError.emit(err);\r\n }\r\n });\r\n }\r\n \r\n //Logout the user and delete the token from Local Storage\r\n logout(): void {\r\n if (localStorage.getItem(this.config.tokenName)) {\r\n localStorage.removeItem(this.config.tokenName);\r\n }\r\n\r\n this.authenticatedUser = null;\r\n this.authenticated = false;\r\n this.authenticatedChanged.emit(false);\r\n }\r\n \r\n validateUser(token: User): void {\r\n this.authenticatedUser = {\r\n admin: false, // This type of authentication has no concept of Admin\r\n displayName: token.displayName,\r\n accountName: token.sAMAccountName,\r\n distinguishedName: token.distinguishedName,\r\n employeeNumber: token.employeeNumber,\r\n memberOf: token.memberOf.join(',')\r\n };\r\n\r\n localStorage.setItem(this.config.tokenName, JSON.stringify(token));\r\n \r\n this.authenticated = true;\r\n this.authenticatedChanged.emit(this.authenticated);\r\n\r\n this.authenticating = false;\r\n this.authenticatingChanged.emit(this.authenticating);\r\n }\r\n\r\n checkForExistingToken(): void {\r\n const token = localStorage.getItem(this.config.tokenName);\r\n if (token) {\r\n this.validateUser(JSON.parse(token) as User);\r\n }\r\n }\r\n //#endregion\r\n}\r\n ","import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\n\r\nimport { ServiceConfig } from './model/service-config';\r\n\r\nimport { AuthenticationObjectService } from './services/authentication-object.service';\r\n\r\n@NgModule({\r\n declarations: [],\r\n imports: [\r\n CommonModule\r\n ],\r\n exports: []\r\n})\r\nexport class AuthenticationObjectModule {\r\n static forRoot(config: ServiceConfig): ModuleWithProviders<AuthenticationObjectModule> {\r\n return {\r\n ngModule: AuthenticationObjectModule,\r\n providers: [\r\n AuthenticationObjectService,\r\n { provide: ServiceConfig, useValue: config }\r\n ]\r\n };\r\n }\r\n\r\n constructor(@Optional() @SkipSelf() parentModule: AuthenticationObjectModule) {\r\n if (parentModule) {\r\n throw new Error(\r\n 'AuthenticationObjectModule is already loaded. Import it in the AppModule only');\r\n }\r\n }\r\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["BaseServiceConfig","i1.ServiceConfig"],"mappings":";;;;;;AAEa,MAAA,aAAa,GAAkB;AACxC,IAAA,MAAM,EAAE,gCAAgC;AACxC,IAAA,SAAS,EAAE,MAAM;;;ACFf,MAAO,aAAc,SAAQA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ngx-lib/authentication/token';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { Injectable, Optional, Component, Inject, Input, NgModule, SkipSelf } from '@angular/core';
|
|
4
|
+
import { JwtHelperService } from '@auth0/angular-jwt';
|
|
5
|
+
import * as i2 from '@angular/common/http';
|
|
6
|
+
import * as i3 from '@cleavelandprice/ngx-lib/sharepoint';
|
|
7
|
+
import { ConfirmationComponent } from '@cleavelandprice/ngx-lib/dialog';
|
|
8
|
+
import * as i4 from '@angular/forms';
|
|
9
|
+
import { UntypedFormGroup, UntypedFormControl, Validators, ReactiveFormsModule } from '@angular/forms';
|
|
10
|
+
import * as i1 from '@angular/material/dialog';
|
|
11
|
+
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
|
|
12
|
+
import * as i3$1 from '@angular/common';
|
|
13
|
+
import { CommonModule } from '@angular/common';
|
|
14
|
+
import * as i5 from '@angular/material/button';
|
|
15
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
16
|
+
import * as i6 from '@angular/material/form-field';
|
|
17
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
18
|
+
import * as i7 from '@angular/material/icon';
|
|
19
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
20
|
+
import * as i8 from '@angular/material/input';
|
|
21
|
+
import { MatInputModule } from '@angular/material/input';
|
|
22
|
+
import * as i9 from '@angular/material/progress-spinner';
|
|
23
|
+
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
24
|
+
|
|
25
|
+
const defaultConfig = {
|
|
26
|
+
apiUrl: 'http://utilityapi/authenticate/token',
|
|
27
|
+
tokenName: 'token',
|
|
28
|
+
deferTokenValidation: true
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
class ServiceConfig extends ServiceConfig$1 {
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class AuthenticationTokenGuiService extends AuthenticationTokenService {
|
|
35
|
+
//#region Lifecycle
|
|
36
|
+
// If a ServiceConfig object is not provided when the module is imported, then default values are pulled in from default-config.ts.
|
|
37
|
+
constructor(config, http, sharePointService) {
|
|
38
|
+
config = Object.assign(Object.assign(Object.assign({}, defaultConfig), config), {
|
|
39
|
+
// Need to force deferTokenValidation here because if a custom config was passed in, deferTokenValidation would have defaulted to false since it's the default boolean value
|
|
40
|
+
// If a custom config wasn't passed in, then deferTokenValidation would have been true from defaultConfig
|
|
41
|
+
deferTokenValidation: true });
|
|
42
|
+
super(config, http);
|
|
43
|
+
this.config = config;
|
|
44
|
+
this.http = http;
|
|
45
|
+
this.sharePointService = sharePointService;
|
|
46
|
+
this.checkForExistingToken();
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region Utilities
|
|
50
|
+
validateUser(token) {
|
|
51
|
+
const jwtHelper = new JwtHelperService();
|
|
52
|
+
const decoded = jwtHelper.decodeToken(token);
|
|
53
|
+
if (jwtHelper.isTokenExpired(token)) {
|
|
54
|
+
this.logout();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
this.authenticatedUser = {
|
|
58
|
+
admin: decoded.role === 'Admin',
|
|
59
|
+
displayName: decoded.displayName,
|
|
60
|
+
accountName: decoded.winaccountname,
|
|
61
|
+
distinguishedName: decoded.distinguishedName,
|
|
62
|
+
employeeNumber: decoded.employeeNumber,
|
|
63
|
+
memberOf: decoded.memberOf
|
|
64
|
+
};
|
|
65
|
+
localStorage.setItem(this.config.tokenName, token);
|
|
66
|
+
this.getPhoto();
|
|
67
|
+
this.authenticated = true;
|
|
68
|
+
this.authenticatedChanged.emit(this.authenticated);
|
|
69
|
+
this.authenticating = false;
|
|
70
|
+
this.authenticatingChanged.emit(this.authenticating);
|
|
71
|
+
}
|
|
72
|
+
getPhoto() {
|
|
73
|
+
this.sharePointService.getPhotos()
|
|
74
|
+
.subscribe(photos => {
|
|
75
|
+
var _a;
|
|
76
|
+
// The user may have been logged out by the time the photos came back
|
|
77
|
+
if (!((_a = this.authenticatedUser) === null || _a === void 0 ? void 0 : _a.employeeNumber)) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const photo = photos.find(pic => pic.employeeNumber === +this.authenticatedUser.employeeNumber);
|
|
81
|
+
if (photo) {
|
|
82
|
+
this.authenticatedUser.photoUrl = photo.encodedAbsUrl;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
AuthenticationTokenGuiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: AuthenticationTokenGuiService, deps: [{ token: ServiceConfig, optional: true }, { token: i2.HttpClient }, { token: i3.SharePointService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
88
|
+
AuthenticationTokenGuiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: AuthenticationTokenGuiService, providedIn: 'root' });
|
|
89
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: AuthenticationTokenGuiService, decorators: [{
|
|
90
|
+
type: Injectable,
|
|
91
|
+
args: [{
|
|
92
|
+
providedIn: 'root'
|
|
93
|
+
}]
|
|
94
|
+
}], ctorParameters: function () {
|
|
95
|
+
return [{ type: ServiceConfig, decorators: [{
|
|
96
|
+
type: Optional
|
|
97
|
+
}] }, { type: i2.HttpClient }, { type: i3.SharePointService }];
|
|
98
|
+
} });
|
|
99
|
+
|
|
100
|
+
class LoginFormComponent {
|
|
101
|
+
constructor(data, dialogRef, authenticationService) {
|
|
102
|
+
var _a;
|
|
103
|
+
this.dialogRef = dialogRef;
|
|
104
|
+
this.authenticationService = authenticationService;
|
|
105
|
+
this.errorMessage = null;
|
|
106
|
+
this.form = new UntypedFormGroup({
|
|
107
|
+
username: new UntypedFormControl(null, [Validators.required]),
|
|
108
|
+
password: new UntypedFormControl(null, [Validators.required]),
|
|
109
|
+
adminGroup: new UntypedFormControl()
|
|
110
|
+
});
|
|
111
|
+
(_a = this.form.get('adminGroup')) === null || _a === void 0 ? void 0 : _a.setValue(data.adminGroup);
|
|
112
|
+
}
|
|
113
|
+
ngOnInit() {
|
|
114
|
+
this.authenticatedChangedSubscription = this.authenticationService.authenticatedChanged
|
|
115
|
+
.subscribe(this.authChangedHandler.bind(this));
|
|
116
|
+
this.authenticationErrorSubscription = this.authenticationService.authenticationError
|
|
117
|
+
.subscribe(this.errorHandler.bind(this));
|
|
118
|
+
}
|
|
119
|
+
ngOnDestroy() {
|
|
120
|
+
this.authenticationErrorSubscription.unsubscribe();
|
|
121
|
+
this.authenticatedChangedSubscription.unsubscribe();
|
|
122
|
+
}
|
|
123
|
+
authenticate() {
|
|
124
|
+
this.errorMessage = null;
|
|
125
|
+
const { username, password, adminGroup } = this.form.value;
|
|
126
|
+
this.authenticationService.login(username, password, adminGroup);
|
|
127
|
+
}
|
|
128
|
+
authChangedHandler(authenticated) {
|
|
129
|
+
if (authenticated) {
|
|
130
|
+
this.dialogRef.close();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
errorHandler(err) {
|
|
134
|
+
console.log('Authentication error', err);
|
|
135
|
+
this.errorMessage = `${err.name}: ${err.statusText}`;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
LoginFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: LoginFormComponent, deps: [{ token: MAT_DIALOG_DATA }, { token: i1.MatDialogRef }, { token: AuthenticationTokenGuiService }], target: i0.ɵɵFactoryTarget.Component });
|
|
139
|
+
LoginFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.1", type: LoginFormComponent, selector: "authentication-login-form", ngImport: i0, template: "<h2 mat-dialog-title>\r\n <span *ngIf=\"!authenticationService.authenticating\">Login</span>\r\n <span *ngIf=\"authenticationService.authenticating\">Authenticating...</span>\r\n</h2>\r\n\r\n<mat-dialog-content>\r\n <div id=\"spinner\" *ngIf=\"authenticationService.authenticating\">\r\n <mat-progress-spinner color=\"primary\" mode=\"indeterminate\"></mat-progress-spinner>\r\n </div>\r\n\r\n <form *ngIf=\"!authenticationService.authenticating\" [formGroup]=\"form\">\r\n <mat-form-field>\r\n <input matInput formControlName=\"username\" placeholder=\"Username\" (keyup.enter)=\"authenticate()\">\r\n </mat-form-field>\r\n\r\n <mat-form-field>\r\n <input matInput formControlName=\"password\" type=\"password\" placeholder=\"Password\" (keyup.enter)=\"authenticate()\">\r\n </mat-form-field>\r\n </form>\r\n\r\n <div *ngIf=\"!authenticationService.authenticating && errorMessage\" id=\"error\">\r\n {{ errorMessage }}\r\n </div>\r\n</mat-dialog-content>\r\n\r\n<mat-dialog-actions *ngIf=\"!authenticationService.authenticating\">\r\n <button mat-raised-button color=\"primary\" (click)=\"authenticate()\"\r\n [disabled]=\"form.invalid\">\r\n <mat-icon fontIcon=\"done\"></mat-icon>\r\n <span>OK</span>\r\n </button>\r\n\r\n <button mat-raised-button (click)=\"dialogRef.close()\">\r\n <mat-icon fontIcon=\"close\"></mat-icon>\r\n <span>Cancel</span>\r\n </button>\r\n</mat-dialog-actions>", styles: ["#spinner{width:100%;height:100%;display:flex;justify-content:center;align-items:center}form{display:grid;gap:1rem}mat-dialog-actions{display:grid;justify-content:center;grid-template-columns:auto auto;gap:1rem}#error{color:red}\n", ".material-icons{font-family:Material Icons;font-weight:400;font-style:normal;font-size:24px;display:inline-block;line-height:1;text-transform:none;letter-spacing:normal;word-wrap:normal;white-space:nowrap;direction:ltr;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;font-feature-settings:\"liga\"}\n"], dependencies: [{ kind: "directive", type: i3$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i4.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i4.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: i5.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: i1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { kind: "directive", type: i1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "directive", type: i1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "component", type: i6.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { kind: "component", type: i7.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i8.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i9.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "diameter", "strokeWidth", "mode", "value"], exportAs: ["matProgressSpinner"] }] });
|
|
140
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: LoginFormComponent, decorators: [{
|
|
141
|
+
type: Component,
|
|
142
|
+
args: [{ selector: 'authentication-login-form', template: "<h2 mat-dialog-title>\r\n <span *ngIf=\"!authenticationService.authenticating\">Login</span>\r\n <span *ngIf=\"authenticationService.authenticating\">Authenticating...</span>\r\n</h2>\r\n\r\n<mat-dialog-content>\r\n <div id=\"spinner\" *ngIf=\"authenticationService.authenticating\">\r\n <mat-progress-spinner color=\"primary\" mode=\"indeterminate\"></mat-progress-spinner>\r\n </div>\r\n\r\n <form *ngIf=\"!authenticationService.authenticating\" [formGroup]=\"form\">\r\n <mat-form-field>\r\n <input matInput formControlName=\"username\" placeholder=\"Username\" (keyup.enter)=\"authenticate()\">\r\n </mat-form-field>\r\n\r\n <mat-form-field>\r\n <input matInput formControlName=\"password\" type=\"password\" placeholder=\"Password\" (keyup.enter)=\"authenticate()\">\r\n </mat-form-field>\r\n </form>\r\n\r\n <div *ngIf=\"!authenticationService.authenticating && errorMessage\" id=\"error\">\r\n {{ errorMessage }}\r\n </div>\r\n</mat-dialog-content>\r\n\r\n<mat-dialog-actions *ngIf=\"!authenticationService.authenticating\">\r\n <button mat-raised-button color=\"primary\" (click)=\"authenticate()\"\r\n [disabled]=\"form.invalid\">\r\n <mat-icon fontIcon=\"done\"></mat-icon>\r\n <span>OK</span>\r\n </button>\r\n\r\n <button mat-raised-button (click)=\"dialogRef.close()\">\r\n <mat-icon fontIcon=\"close\"></mat-icon>\r\n <span>Cancel</span>\r\n </button>\r\n</mat-dialog-actions>", styles: ["#spinner{width:100%;height:100%;display:flex;justify-content:center;align-items:center}form{display:grid;gap:1rem}mat-dialog-actions{display:grid;justify-content:center;grid-template-columns:auto auto;gap:1rem}#error{color:red}\n", ".material-icons{font-family:Material Icons;font-weight:400;font-style:normal;font-size:24px;display:inline-block;line-height:1;text-transform:none;letter-spacing:normal;word-wrap:normal;white-space:nowrap;direction:ltr;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;font-feature-settings:\"liga\"}\n"] }]
|
|
143
|
+
}], ctorParameters: function () {
|
|
144
|
+
return [{ type: undefined, decorators: [{
|
|
145
|
+
type: Inject,
|
|
146
|
+
args: [MAT_DIALOG_DATA]
|
|
147
|
+
}] }, { type: i1.MatDialogRef }, { type: AuthenticationTokenGuiService }];
|
|
148
|
+
} });
|
|
149
|
+
|
|
150
|
+
class LoginComponent {
|
|
151
|
+
constructor(dialog, authenticationService) {
|
|
152
|
+
this.dialog = dialog;
|
|
153
|
+
this.authenticationService = authenticationService;
|
|
154
|
+
}
|
|
155
|
+
login() {
|
|
156
|
+
this.dialog.open(LoginFormComponent, {
|
|
157
|
+
data: { adminGroup: this.adminGroup }
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
confirmLogout() {
|
|
161
|
+
this.dialog.open(ConfirmationComponent, {
|
|
162
|
+
data: { message: `Are you sure you want to logout?` }
|
|
163
|
+
})
|
|
164
|
+
.afterClosed()
|
|
165
|
+
.subscribe(result => {
|
|
166
|
+
if (result) {
|
|
167
|
+
this.authenticationService.logout();
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
LoginComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: LoginComponent, deps: [{ token: i1.MatDialog }, { token: AuthenticationTokenGuiService }], target: i0.ɵɵFactoryTarget.Component });
|
|
173
|
+
LoginComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.1", type: LoginComponent, selector: "authentication-login", inputs: { adminGroup: "adminGroup" }, ngImport: i0, template: "<div id=\"user-id\">\r\n <!-- Logged out -->\r\n <mat-icon *ngIf=\"!authenticationService.authenticated\"\r\n fontIcon=\"account_circle\"\r\n matTooltip=\"Login\"\r\n (click)=\"login()\">\r\n </mat-icon>\r\n\r\n <!-- Logged in -->\r\n <ng-container *ngIf=\"authenticationService.authenticated\">\r\n <!-- With photo -->\r\n <img *ngIf=\"authenticationService.authenticatedUser?.photoUrl\"\r\n id=\"authenticated-user-image\"\r\n [src]=\"authenticationService.authenticatedUser?.photoUrl\"\r\n matTooltip=\"Logout\"\r\n (click)=\"confirmLogout()\" />\r\n \r\n <!-- Without photo -->\r\n <mat-icon *ngIf=\"!authenticationService.authenticatedUser?.photoUrl\"\r\n fontIcon=\"account_circle\"\r\n matTooltip=\"Logout\"\r\n (click)=\"confirmLogout()\">\r\n </mat-icon>\r\n \r\n <!-- Name -->\r\n <div id=\"user-name\">\r\n {{ authenticationService.authenticatedUser?.displayName }}\r\n </div>\r\n </ng-container>\r\n</div>", styles: ["#user-id{display:flex;height:2em;padding:.3em;font-family:Verdana,Geneva,Tahoma,sans-serif}mat-icon{font-size:2em!important;height:2em!important;width:2em!important}img{border-radius:100%;width:2em;height:2em}#user-id>div{display:flex;align-items:center;height:100%;margin-left:.75em;font-size:1.15em}\n", ".material-icons{font-family:Material Icons;font-weight:400;font-style:normal;font-size:24px;display:inline-block;line-height:1;text-transform:none;letter-spacing:normal;word-wrap:normal;white-space:nowrap;direction:ltr;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;font-feature-settings:\"liga\"}\n"], dependencies: [{ kind: "directive", type: i3$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i7.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] });
|
|
174
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: LoginComponent, decorators: [{
|
|
175
|
+
type: Component,
|
|
176
|
+
args: [{ selector: 'authentication-login', template: "<div id=\"user-id\">\r\n <!-- Logged out -->\r\n <mat-icon *ngIf=\"!authenticationService.authenticated\"\r\n fontIcon=\"account_circle\"\r\n matTooltip=\"Login\"\r\n (click)=\"login()\">\r\n </mat-icon>\r\n\r\n <!-- Logged in -->\r\n <ng-container *ngIf=\"authenticationService.authenticated\">\r\n <!-- With photo -->\r\n <img *ngIf=\"authenticationService.authenticatedUser?.photoUrl\"\r\n id=\"authenticated-user-image\"\r\n [src]=\"authenticationService.authenticatedUser?.photoUrl\"\r\n matTooltip=\"Logout\"\r\n (click)=\"confirmLogout()\" />\r\n \r\n <!-- Without photo -->\r\n <mat-icon *ngIf=\"!authenticationService.authenticatedUser?.photoUrl\"\r\n fontIcon=\"account_circle\"\r\n matTooltip=\"Logout\"\r\n (click)=\"confirmLogout()\">\r\n </mat-icon>\r\n \r\n <!-- Name -->\r\n <div id=\"user-name\">\r\n {{ authenticationService.authenticatedUser?.displayName }}\r\n </div>\r\n </ng-container>\r\n</div>", styles: ["#user-id{display:flex;height:2em;padding:.3em;font-family:Verdana,Geneva,Tahoma,sans-serif}mat-icon{font-size:2em!important;height:2em!important;width:2em!important}img{border-radius:100%;width:2em;height:2em}#user-id>div{display:flex;align-items:center;height:100%;margin-left:.75em;font-size:1.15em}\n", ".material-icons{font-family:Material Icons;font-weight:400;font-style:normal;font-size:24px;display:inline-block;line-height:1;text-transform:none;letter-spacing:normal;word-wrap:normal;white-space:nowrap;direction:ltr;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;font-feature-settings:\"liga\"}\n"] }]
|
|
177
|
+
}], ctorParameters: function () { return [{ type: i1.MatDialog }, { type: AuthenticationTokenGuiService }]; }, propDecorators: { adminGroup: [{
|
|
178
|
+
type: Input
|
|
179
|
+
}] } });
|
|
180
|
+
|
|
181
|
+
class AuthenticationTokenGuiModule {
|
|
182
|
+
constructor(parentModule) {
|
|
183
|
+
if (parentModule) {
|
|
184
|
+
throw new Error('AuthenticationTokenGuiModule is already loaded. Import it in the AppModule only');
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
static forRoot(config) {
|
|
188
|
+
return {
|
|
189
|
+
ngModule: AuthenticationTokenGuiModule,
|
|
190
|
+
providers: [
|
|
191
|
+
AuthenticationTokenGuiService,
|
|
192
|
+
{ provide: ServiceConfig, useValue: config }
|
|
193
|
+
]
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
AuthenticationTokenGuiModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: AuthenticationTokenGuiModule, deps: [{ token: AuthenticationTokenGuiModule, optional: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.NgModule });
|
|
198
|
+
AuthenticationTokenGuiModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.1", ngImport: i0, type: AuthenticationTokenGuiModule, declarations: [LoginComponent,
|
|
199
|
+
LoginFormComponent], imports: [CommonModule,
|
|
200
|
+
ReactiveFormsModule,
|
|
201
|
+
MatButtonModule,
|
|
202
|
+
MatDialogModule,
|
|
203
|
+
MatFormFieldModule,
|
|
204
|
+
MatIconModule,
|
|
205
|
+
MatInputModule,
|
|
206
|
+
MatProgressSpinnerModule], exports: [LoginComponent,
|
|
207
|
+
LoginFormComponent] });
|
|
208
|
+
AuthenticationTokenGuiModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: AuthenticationTokenGuiModule, imports: [CommonModule,
|
|
209
|
+
ReactiveFormsModule,
|
|
210
|
+
MatButtonModule,
|
|
211
|
+
MatDialogModule,
|
|
212
|
+
MatFormFieldModule,
|
|
213
|
+
MatIconModule,
|
|
214
|
+
MatInputModule,
|
|
215
|
+
MatProgressSpinnerModule] });
|
|
216
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: AuthenticationTokenGuiModule, decorators: [{
|
|
217
|
+
type: NgModule,
|
|
218
|
+
args: [{
|
|
219
|
+
declarations: [
|
|
220
|
+
LoginComponent,
|
|
221
|
+
LoginFormComponent
|
|
222
|
+
],
|
|
223
|
+
imports: [
|
|
224
|
+
CommonModule,
|
|
225
|
+
ReactiveFormsModule,
|
|
226
|
+
MatButtonModule,
|
|
227
|
+
MatDialogModule,
|
|
228
|
+
MatFormFieldModule,
|
|
229
|
+
MatIconModule,
|
|
230
|
+
MatInputModule,
|
|
231
|
+
MatProgressSpinnerModule
|
|
232
|
+
],
|
|
233
|
+
exports: [
|
|
234
|
+
LoginComponent,
|
|
235
|
+
LoginFormComponent
|
|
236
|
+
]
|
|
237
|
+
}]
|
|
238
|
+
}], ctorParameters: function () {
|
|
239
|
+
return [{ type: AuthenticationTokenGuiModule, decorators: [{
|
|
240
|
+
type: Optional
|
|
241
|
+
}, {
|
|
242
|
+
type: SkipSelf
|
|
243
|
+
}] }];
|
|
244
|
+
} });
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Generated bundle index. Do not edit.
|
|
248
|
+
*/
|
|
249
|
+
|
|
250
|
+
export { AuthenticationTokenGuiModule, AuthenticationTokenGuiService, LoginComponent, LoginFormComponent, ServiceConfig, defaultConfig };
|
|
251
|
+
//# sourceMappingURL=cleavelandprice-ngx-lib-authentication-token-gui.mjs.map
|