@cleavelandprice/ngx-lib 3.7.2 → 3.7.3
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/authentication/model/authentication-request.d.ts +2 -0
- package/authentication/model/service-config.d.ts +2 -1
- package/authentication/object/model/service-config.d.ts +1 -1
- package/authentication/object/services/authentication.service.d.ts +1 -1
- package/authentication/token/gui/components/login/login.component.d.ts +2 -1
- package/authentication/token/gui/components/login-form/login-form.component.d.ts +1 -0
- package/authentication/token/gui/model/login-form-data.d.ts +1 -0
- package/authentication/token/gui/model/service-config.d.ts +1 -1
- package/authentication/token/model/service-config.d.ts +1 -1
- package/authentication/token/services/authentication.service.d.ts +1 -1
- package/esm2020/authentication/model/authentication-request.mjs +1 -1
- package/esm2020/authentication/model/service-config.mjs +3 -2
- package/esm2020/authentication/object/model/service-config.mjs +3 -3
- package/esm2020/authentication/object/services/authentication.service.mjs +7 -5
- package/esm2020/authentication/token/gui/components/login/login.component.mjs +8 -3
- package/esm2020/authentication/token/gui/components/login-form/login-form.component.mjs +6 -4
- package/esm2020/authentication/token/gui/model/login-form-data.mjs +1 -1
- package/esm2020/authentication/token/gui/model/service-config.mjs +3 -3
- package/esm2020/authentication/token/model/service-config.mjs +3 -3
- package/esm2020/authentication/token/services/authentication.service.mjs +7 -5
- package/fesm2015/cleavelandprice-ngx-lib-authentication-object.mjs +8 -6
- package/fesm2015/cleavelandprice-ngx-lib-authentication-object.mjs.map +1 -1
- package/fesm2015/cleavelandprice-ngx-lib-authentication-token-gui.mjs +15 -8
- package/fesm2015/cleavelandprice-ngx-lib-authentication-token-gui.mjs.map +1 -1
- package/fesm2015/cleavelandprice-ngx-lib-authentication-token.mjs +8 -6
- package/fesm2015/cleavelandprice-ngx-lib-authentication-token.mjs.map +1 -1
- package/fesm2015/cleavelandprice-ngx-lib-authentication.mjs +2 -1
- package/fesm2015/cleavelandprice-ngx-lib-authentication.mjs.map +1 -1
- package/fesm2015/cleavelandprice-ngx-lib-dialog.mjs +1 -0
- package/fesm2020/cleavelandprice-ngx-lib-authentication-object.mjs +8 -6
- package/fesm2020/cleavelandprice-ngx-lib-authentication-object.mjs.map +1 -1
- package/fesm2020/cleavelandprice-ngx-lib-authentication-token-gui.mjs +14 -7
- package/fesm2020/cleavelandprice-ngx-lib-authentication-token-gui.mjs.map +1 -1
- package/fesm2020/cleavelandprice-ngx-lib-authentication-token.mjs +8 -6
- package/fesm2020/cleavelandprice-ngx-lib-authentication-token.mjs.map +1 -1
- package/fesm2020/cleavelandprice-ngx-lib-authentication.mjs +2 -1
- package/fesm2020/cleavelandprice-ngx-lib-authentication.mjs.map +1 -1
- package/fesm2020/cleavelandprice-ngx-lib-dialog.mjs +1 -0
- package/package.json +1 -1
|
@@ -27,8 +27,8 @@ import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
|
|
27
27
|
//import { ServiceConfig as NgxLibServiceConfig } from '@cleavelandprice/ngx-lib';
|
|
28
28
|
class ServiceConfig extends ServiceConfig$1 {
|
|
29
29
|
// See the comment in the library's main service-config.ts file for an explanation
|
|
30
|
-
constructor(useSsl_or_customApiUrl = false, showRememberMeOption = true, tokenName = 'token', authenticateEndpoint = '/authenticate/token') {
|
|
31
|
-
super(useSsl_or_customApiUrl, tokenName, authenticateEndpoint);
|
|
30
|
+
constructor(useSsl_or_customApiUrl = false, showRememberMeOption = true, appName = undefined, tokenName = 'token', authenticateEndpoint = '/authenticate/token') {
|
|
31
|
+
super(useSsl_or_customApiUrl, appName, tokenName, authenticateEndpoint);
|
|
32
32
|
this.showRememberMeOption = showRememberMeOption;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -108,15 +108,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImpor
|
|
|
108
108
|
|
|
109
109
|
class LoginFormComponent {
|
|
110
110
|
constructor(data, dialogRef, authenticationService) {
|
|
111
|
-
var _a;
|
|
111
|
+
var _a, _b;
|
|
112
112
|
this.dialogRef = dialogRef;
|
|
113
113
|
this.authenticationService = authenticationService;
|
|
114
114
|
this.form = new FormGroup({
|
|
115
115
|
username: new FormControl(null, [Validators.required]),
|
|
116
116
|
password: new FormControl(null, [Validators.required]),
|
|
117
|
-
adminGroup: new FormControl()
|
|
117
|
+
adminGroup: new FormControl(),
|
|
118
|
+
additionalInfo: new FormControl()
|
|
118
119
|
});
|
|
119
120
|
(_a = this.form.get('adminGroup')) === null || _a === void 0 ? void 0 : _a.setValue(data.adminGroup);
|
|
121
|
+
(_b = this.form.get('additionalInfo')) === null || _b === void 0 ? void 0 : _b.setValue(data.additionalInfo);
|
|
120
122
|
}
|
|
121
123
|
ngOnInit() {
|
|
122
124
|
this.authenticatedChangedSubscription = this.authenticationService.authenticatedChanged
|
|
@@ -130,8 +132,8 @@ class LoginFormComponent {
|
|
|
130
132
|
}
|
|
131
133
|
authenticate() {
|
|
132
134
|
this.errorMessage = undefined;
|
|
133
|
-
const { username, password, adminGroup } = this.form.value;
|
|
134
|
-
this.authenticationService.login(username, password, adminGroup);
|
|
135
|
+
const { username, password, adminGroup, additionalInfo } = this.form.value;
|
|
136
|
+
this.authenticationService.login(username, password, adminGroup, additionalInfo);
|
|
135
137
|
}
|
|
136
138
|
authChangedHandler(authenticated) {
|
|
137
139
|
if (authenticated) {
|
|
@@ -173,7 +175,10 @@ class LoginComponent {
|
|
|
173
175
|
}
|
|
174
176
|
login() {
|
|
175
177
|
this.dialog.open(LoginFormComponent, {
|
|
176
|
-
data: {
|
|
178
|
+
data: {
|
|
179
|
+
adminGroup: this.adminGroup,
|
|
180
|
+
additionalInfo: this.additionalInfo
|
|
181
|
+
}
|
|
177
182
|
});
|
|
178
183
|
}
|
|
179
184
|
confirmLogout() {
|
|
@@ -189,12 +194,14 @@ class LoginComponent {
|
|
|
189
194
|
}
|
|
190
195
|
}
|
|
191
196
|
LoginComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: LoginComponent, deps: [{ token: i1.MatDialog }, { token: AuthenticationService }], target: i0.ɵɵFactoryTarget.Component });
|
|
192
|
-
LoginComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", type: LoginComponent, selector: "cp-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"] }] });
|
|
197
|
+
LoginComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", type: LoginComponent, selector: "cp-login", inputs: { adminGroup: "adminGroup", additionalInfo: "additionalInfo" }, 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"] }] });
|
|
193
198
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: LoginComponent, decorators: [{
|
|
194
199
|
type: Component,
|
|
195
200
|
args: [{ selector: 'cp-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"] }]
|
|
196
201
|
}], ctorParameters: function () { return [{ type: i1.MatDialog }, { type: AuthenticationService }]; }, propDecorators: { adminGroup: [{
|
|
197
202
|
type: Input
|
|
203
|
+
}], additionalInfo: [{
|
|
204
|
+
type: Input
|
|
198
205
|
}] } });
|
|
199
206
|
|
|
200
207
|
class GuiModule {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleavelandprice-ngx-lib-authentication-token-gui.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/authentication/token/gui/src/model/service-config.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/gui/src/services/authentication.service.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/gui/src/components/login-form/login-form.component.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/gui/src/components/login-form/login-form.component.html","../../../../projects/cleavelandprice/ngx-lib/authentication/token/gui/src/components/login/login.component.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/gui/src/components/login/login.component.html","../../../../projects/cleavelandprice/ngx-lib/authentication/token/gui/src/token-gui.module.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/gui/src/cleavelandprice-ngx-lib-authentication-token-gui.ts"],"sourcesContent":["//import { ServiceConfig as NgxLibServiceConfig } from '@cleavelandprice/ngx-lib';\r\nimport { ServiceConfig as BaseServiceConfig } from '@cleavelandprice/ngx-lib/authentication/token';\r\n\r\nexport class ServiceConfig extends BaseServiceConfig {\r\n // See the comment in the library's main service-config.ts file for an explanation\r\n constructor(useSsl_or_customApiUrl: boolean | string = false,\r\n public showRememberMeOption = true,\r\n tokenName = 'token',\r\n authenticateEndpoint = '/authenticate/token'\r\n ) {\r\n super(useSsl_or_customApiUrl, tokenName, authenticateEndpoint);\r\n }\r\n}","import { Injectable, Optional } from '@angular/core';\r\nimport { HttpClient } from '@angular/common/http';\r\nimport { JwtHelperService } from '@auth0/angular-jwt';\r\n\r\nimport { SharePointService } from '@cleavelandprice/ngx-lib/sharepoint';\r\n\r\nimport {\r\n AuthenticationService as TokenAuthenticationService,\r\n AuthenticationToken\r\n} from '@cleavelandprice/ngx-lib/authentication/token';\r\n\r\nimport { ServiceConfig } from '../model/service-config';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class AuthenticationService extends TokenAuthenticationService {\r\n //#region Lifecycle\r\n constructor(@Optional() override config: ServiceConfig,\r\n override http: HttpClient,\r\n private sharePointService: SharePointService) {\r\n\r\n config = config ?? new ServiceConfig();\r\n /*config = {\r\n ...new ServiceConfig(),\r\n ...config,\r\n\r\n // 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\r\n // If a custom config wasn't passed in, then deferTokenValidation would have been true from defaultConfig\r\n deferTokenValidation: true\r\n };*/\r\n\r\n // 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\r\n // If a custom config wasn't passed in, then deferTokenValidation would have been true from defaultConfig\r\n config.deferTokenValidation = true\r\n\r\n super(config, http);\r\n\r\n this.checkForExistingToken();\r\n }\r\n //#endregion\r\n\r\n //#region Utilities\r\n override validateUser(token: string): void {\r\n const jwtHelper = new JwtHelperService();\r\n const decoded = jwtHelper.decodeToken(token) as AuthenticationToken;\r\n\r\n if (jwtHelper.isTokenExpired(token)) {\r\n this.logout();\r\n return;\r\n }\r\n\r\n this.authenticatedUser = {\r\n admin: decoded.role === 'Admin',\r\n displayName: decoded.displayName,\r\n accountName: decoded.winaccountname,\r\n distinguishedName: decoded.distinguishedName,\r\n employeeNumber: decoded.employeeNumber,\r\n memberOf: decoded.memberOf\r\n };\r\n\r\n this.storage.setItem(this.config.tokenName, token);\r\n\r\n this.getPhoto();\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 private getPhoto(): void {\r\n this.sharePointService.getPhotos()\r\n .subscribe(photos => {\r\n // The user may have been logged out by the time the photos came back\r\n if (!this.authenticatedUser?.employeeNumber) {\r\n return;\r\n }\r\n\r\n const photo = photos.find(pic => pic.employeeNumber === +this.authenticatedUser!.employeeNumber);\r\n\r\n if (photo) {\r\n this.authenticatedUser.photoUrl = photo.encodedAbsUrl;\r\n }\r\n });\r\n }\r\n //#endregion\r\n}","import { Component, Inject, OnInit, OnDestroy } from '@angular/core';\r\nimport { FormGroup, Validators, FormControl } from '@angular/forms';\r\nimport { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';\r\nimport { Subscription } from 'rxjs';\r\n\r\nimport { LoginFormData } from '../../model/login-form-data';\r\nimport { AuthenticationService } from '../../services/authentication.service';\r\n\r\n@Component({\r\n templateUrl: './login-form.component.html',\r\n styleUrls: [\r\n './login-form.component.css',\r\n '../../../../../../styles/mat-icon.css'\r\n ]\r\n})\r\nexport class LoginFormComponent implements OnInit, OnDestroy {\r\n errorMessage: string | undefined;\r\n authenticatedChangedSubscription!: Subscription;\r\n authenticationErrorSubscription!: Subscription;\r\n\r\n form = new FormGroup({\r\n username: new FormControl(null, [ Validators.required ]),\r\n password: new FormControl(null, [ Validators.required ]),\r\n adminGroup: new FormControl()\r\n });\r\n\r\n constructor(@Inject(MAT_DIALOG_DATA) data: LoginFormData,\r\n public dialogRef: MatDialogRef<LoginFormComponent>,\r\n public authenticationService: AuthenticationService) {\r\n\r\n this.form.get('adminGroup')?.setValue(data.adminGroup);\r\n }\r\n\r\n ngOnInit(): void {\r\n this.authenticatedChangedSubscription = this.authenticationService.authenticatedChanged\r\n .subscribe(this.authChangedHandler.bind(this));\r\n\r\n this.authenticationErrorSubscription = this.authenticationService.authenticationError\r\n .subscribe(this.errorHandler.bind(this));\r\n }\r\n\r\n ngOnDestroy(): void {\r\n this.authenticationErrorSubscription.unsubscribe();\r\n this.authenticatedChangedSubscription.unsubscribe();\r\n }\r\n\r\n authenticate() {\r\n this.errorMessage = undefined;\r\n const { username, password, adminGroup } = this.form.value;\r\n this.authenticationService.login(username!, password!, adminGroup);\r\n }\r\n\r\n private authChangedHandler(authenticated: boolean): void {\r\n if (authenticated) {\r\n this.dialogRef.close();\r\n }\r\n }\r\n\r\n private errorHandler(err: any): void {\r\n console.log('Authentication error', err);\r\n this.errorMessage = `${err.name}: ${err.statusText}`;\r\n }\r\n\r\n changeTokenStorageMode(checked: boolean): void {\r\n const keyName = 'storeTokenInSession';\r\n\r\n if (checked) {\r\n if (localStorage.getItem(keyName)) {\r\n localStorage.removeItem(keyName);\r\n }\r\n } else {\r\n localStorage.setItem(keyName, 'true');\r\n }\r\n }\r\n}\r\n","<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\r\n <mat-slide-toggle *ngIf=\"authenticationService.config.showRememberMeOption\" [checked]=\"!authenticationService.useSessionStorage\" (change)=\"changeTokenStorageMode($event.checked)\">\r\n Remember me next time\r\n </mat-slide-toggle>\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>","import { Component, Input } from '@angular/core';\r\nimport { MatDialog } from '@angular/material/dialog';\r\nimport { ConfirmationComponent } from '@cleavelandprice/ngx-lib/dialog';\r\n\r\nimport { LoginFormComponent } from '../login-form/login-form.component';\r\nimport { AuthenticationService } from '../../services/authentication.service';\r\n\r\n@Component({\r\n selector: 'cp-login',\r\n templateUrl: './login.component.html',\r\n styleUrls: [\r\n './login.component.css',\r\n '../../../../../../styles/mat-icon.css'\r\n ]\r\n})\r\nexport class LoginComponent {\r\n @Input() adminGroup!: string;\r\n\r\n constructor(private dialog: MatDialog,\r\n public authenticationService: AuthenticationService) {\r\n }\r\n\r\n login(): void {\r\n this.dialog.open(LoginFormComponent, {\r\n data: { adminGroup: this.adminGroup }\r\n });\r\n }\r\n\r\n confirmLogout(): void {\r\n this.dialog.open(ConfirmationComponent, {\r\n data: { message: `Are you sure you want to logout?` }\r\n })\r\n .afterClosed()\r\n .subscribe(result => {\r\n if (result) {\r\n this.authenticationService.logout();\r\n }\r\n });\r\n }\r\n}\r\n","<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>","import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { ReactiveFormsModule } from '@angular/forms';\r\n\r\nimport { MatButtonModule } from '@angular/material/button';\r\nimport { MatDialogModule } from '@angular/material/dialog';\r\nimport { MatFormFieldModule } from '@angular/material/form-field';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { MatInputModule } from '@angular/material/input';\r\nimport { MatProgressSpinnerModule } from '@angular/material/progress-spinner';\r\nimport { MatSlideToggleModule } from '@angular/material/slide-toggle';\r\n\r\nimport { ServiceConfig } from './model/service-config';\r\n\r\nimport { AuthenticationService } from './services/authentication.service';\r\n\r\nimport { LoginComponent } from './components/login/login.component';\r\nimport { LoginFormComponent } from './components/login-form/login-form.component';\r\n\r\n@NgModule({\r\n declarations: [\r\n LoginComponent,\r\n LoginFormComponent\r\n ],\r\n imports: [\r\n CommonModule,\r\n ReactiveFormsModule,\r\n \r\n MatButtonModule,\r\n MatDialogModule,\r\n MatFormFieldModule,\r\n MatIconModule,\r\n MatInputModule,\r\n MatProgressSpinnerModule,\r\n MatSlideToggleModule\r\n ],\r\n exports: [\r\n LoginComponent,\r\n LoginFormComponent\r\n ]\r\n})\r\nexport class GuiModule {\r\n static forRoot(config: ServiceConfig): ModuleWithProviders<GuiModule> {\r\n return {\r\n ngModule: GuiModule,\r\n providers: [\r\n AuthenticationService,\r\n { provide: ServiceConfig, useValue: config }\r\n ]\r\n };\r\n }\r\n\r\n constructor(@Optional() @SkipSelf() parentModule: GuiModule) {\r\n if (parentModule) {\r\n throw new Error(\r\n 'GuiModule 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","TokenAuthenticationService","i1.ServiceConfig","i2.AuthenticationService","i3","i4"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAGM,MAAO,aAAc,SAAQA,eAAiB,CAAA;;AAEhD,IAAA,WAAA,CAAY,sBAA2C,GAAA,KAAK,EACjD,oBAAA,GAAuB,IAAI,EAClC,SAAS,GAAG,OAAO,EACnB,oBAAoB,GAAG,qBAAqB,EAAA;AAE5C,QAAA,KAAK,CAAC,sBAAsB,EAAE,SAAS,EAAE,oBAAoB,CAAC,CAAC;AAJxD,QAAA,IAAoB,CAAA,oBAAA,GAApB,oBAAoB,CAAO;KAKrC;AACJ;;ACIK,MAAO,qBAAsB,SAAQC,uBAA0B,CAAA;;AAEjE,IAAA,WAAA,CAAiC,MAAqB,EACnC,IAAgB,EACjB,iBAAoC,EAAA;QAE1C,MAAM,GAAG,MAAM,KAAA,IAAA,IAAN,MAAM,KAAA,KAAA,CAAA,GAAN,MAAM,GAAI,IAAI,aAAa,EAAE,CAAC;AACvC;;;;;;;AAOI;;;AAIJ,QAAA,MAAM,CAAC,oBAAoB,GAAG,IAAI,CAAA;AAElC,QAAA,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAlBC,QAAA,IAAM,CAAA,MAAA,GAAN,MAAM,CAAe;AACnC,QAAA,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAY;AACjB,QAAA,IAAiB,CAAA,iBAAA,GAAjB,iBAAiB,CAAmB;QAkB1C,IAAI,CAAC,qBAAqB,EAAE,CAAC;KAC1C;;;AAIQ,IAAA,YAAY,CAAC,KAAa,EAAA;AACjC,QAAA,MAAM,SAAS,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,SAAS,CAAC,WAAW,CAAC,KAAK,CAAwB,CAAC;AAEpE,QAAA,IAAI,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BlB,cAAc;AACd,QAAA,kBAAkB,aAGlB,YAAY;QACZ,mBAAmB;QAEnB,eAAe;QACf,eAAe;QACf,kBAAkB;QAClB,aAAa;QACb,cAAc;QACd,wBAAwB;AACxB,QAAA,oBAAoB,aAGpB,cAAc;QACd,kBAAkB,CAAA,EAAA,CAAA,CAAA;AAGT,SAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,SAAS,YAhBlB,YAAY;QACZ,mBAAmB;QAEnB,eAAe;QACf,eAAe;QACf,kBAAkB;QAClB,aAAa;QACb,cAAc;QACd,wBAAwB;QACxB,oBAAoB,CAAA,EAAA,CAAA,CAAA;2FAOX,SAAS,EAAA,UAAA,EAAA,CAAA;kBAtBrB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE;wBACZ,cAAc;wBACd,kBAAkB;AACnB,qBAAA;AACD,oBAAA,OAAO,EAAE;wBACP,YAAY;wBACZ,mBAAmB;wBAEnB,eAAe;wBACf,eAAe;wBACf,kBAAkB;wBAClB,aAAa;wBACb,cAAc;wBACd,wBAAwB;wBACxB,oBAAoB;AACrB,qBAAA;AACD,oBAAA,OAAO,EAAE;wBACP,cAAc;wBACd,kBAAkB;AACnB,qBAAA;iBACF,CAAA;;;8BAYc,QAAQ;;8BAAI,QAAQ;;;;ACpDnC;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"cleavelandprice-ngx-lib-authentication-token-gui.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/authentication/token/gui/src/model/service-config.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/gui/src/services/authentication.service.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/gui/src/components/login-form/login-form.component.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/gui/src/components/login-form/login-form.component.html","../../../../projects/cleavelandprice/ngx-lib/authentication/token/gui/src/components/login/login.component.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/gui/src/components/login/login.component.html","../../../../projects/cleavelandprice/ngx-lib/authentication/token/gui/src/token-gui.module.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/gui/src/cleavelandprice-ngx-lib-authentication-token-gui.ts"],"sourcesContent":["//import { ServiceConfig as NgxLibServiceConfig } from '@cleavelandprice/ngx-lib';\r\nimport { ServiceConfig as BaseServiceConfig } from '@cleavelandprice/ngx-lib/authentication/token';\r\n\r\nexport class ServiceConfig extends BaseServiceConfig {\r\n // See the comment in the library's main service-config.ts file for an explanation\r\n constructor(useSsl_or_customApiUrl: boolean | string = false,\r\n public showRememberMeOption = true,\r\n appName: string | undefined = undefined,\r\n tokenName = 'token',\r\n authenticateEndpoint = '/authenticate/token'\r\n ) {\r\n super(useSsl_or_customApiUrl, appName, tokenName, authenticateEndpoint);\r\n }\r\n}","import { Injectable, Optional } from '@angular/core';\r\nimport { HttpClient } from '@angular/common/http';\r\nimport { JwtHelperService } from '@auth0/angular-jwt';\r\n\r\nimport { SharePointService } from '@cleavelandprice/ngx-lib/sharepoint';\r\n\r\nimport {\r\n AuthenticationService as TokenAuthenticationService,\r\n AuthenticationToken\r\n} from '@cleavelandprice/ngx-lib/authentication/token';\r\n\r\nimport { ServiceConfig } from '../model/service-config';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class AuthenticationService extends TokenAuthenticationService {\r\n //#region Lifecycle\r\n constructor(@Optional() override config: ServiceConfig,\r\n override http: HttpClient,\r\n private sharePointService: SharePointService) {\r\n\r\n config = config ?? new ServiceConfig();\r\n /*config = {\r\n ...new ServiceConfig(),\r\n ...config,\r\n\r\n // 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\r\n // If a custom config wasn't passed in, then deferTokenValidation would have been true from defaultConfig\r\n deferTokenValidation: true\r\n };*/\r\n\r\n // 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\r\n // If a custom config wasn't passed in, then deferTokenValidation would have been true from defaultConfig\r\n config.deferTokenValidation = true\r\n\r\n super(config, http);\r\n\r\n this.checkForExistingToken();\r\n }\r\n //#endregion\r\n\r\n //#region Utilities\r\n override validateUser(token: string): void {\r\n const jwtHelper = new JwtHelperService();\r\n const decoded = jwtHelper.decodeToken(token) as AuthenticationToken;\r\n\r\n if (jwtHelper.isTokenExpired(token)) {\r\n this.logout();\r\n return;\r\n }\r\n\r\n this.authenticatedUser = {\r\n admin: decoded.role === 'Admin',\r\n displayName: decoded.displayName,\r\n accountName: decoded.winaccountname,\r\n distinguishedName: decoded.distinguishedName,\r\n employeeNumber: decoded.employeeNumber,\r\n memberOf: decoded.memberOf\r\n };\r\n\r\n this.storage.setItem(this.config.tokenName, token);\r\n\r\n this.getPhoto();\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 private getPhoto(): void {\r\n this.sharePointService.getPhotos()\r\n .subscribe(photos => {\r\n // The user may have been logged out by the time the photos came back\r\n if (!this.authenticatedUser?.employeeNumber) {\r\n return;\r\n }\r\n\r\n const photo = photos.find(pic => pic.employeeNumber === +this.authenticatedUser!.employeeNumber);\r\n\r\n if (photo) {\r\n this.authenticatedUser.photoUrl = photo.encodedAbsUrl;\r\n }\r\n });\r\n }\r\n //#endregion\r\n}","import { Component, Inject, OnInit, OnDestroy } from '@angular/core';\r\nimport { FormGroup, Validators, FormControl } from '@angular/forms';\r\nimport { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';\r\nimport { Subscription } from 'rxjs';\r\n\r\nimport { LoginFormData } from '../../model/login-form-data';\r\nimport { AuthenticationService } from '../../services/authentication.service';\r\n\r\n@Component({\r\n templateUrl: './login-form.component.html',\r\n styleUrls: [\r\n './login-form.component.css',\r\n '../../../../../../styles/mat-icon.css'\r\n ]\r\n})\r\nexport class LoginFormComponent implements OnInit, OnDestroy {\r\n errorMessage: string | undefined;\r\n authenticatedChangedSubscription!: Subscription;\r\n authenticationErrorSubscription!: Subscription;\r\n\r\n form = new FormGroup({\r\n username: new FormControl(null, [ Validators.required ]),\r\n password: new FormControl(null, [ Validators.required ]),\r\n adminGroup: new FormControl(),\r\n additionalInfo: new FormControl()\r\n });\r\n\r\n constructor(@Inject(MAT_DIALOG_DATA) data: LoginFormData,\r\n public dialogRef: MatDialogRef<LoginFormComponent>,\r\n public authenticationService: AuthenticationService) {\r\n\r\n this.form.get('adminGroup')?.setValue(data.adminGroup);\r\n this.form.get('additionalInfo')?.setValue(data.additionalInfo);\r\n }\r\n\r\n ngOnInit(): void {\r\n this.authenticatedChangedSubscription = this.authenticationService.authenticatedChanged\r\n .subscribe(this.authChangedHandler.bind(this));\r\n\r\n this.authenticationErrorSubscription = this.authenticationService.authenticationError\r\n .subscribe(this.errorHandler.bind(this));\r\n }\r\n\r\n ngOnDestroy(): void {\r\n this.authenticationErrorSubscription.unsubscribe();\r\n this.authenticatedChangedSubscription.unsubscribe();\r\n }\r\n\r\n authenticate() {\r\n this.errorMessage = undefined;\r\n const { username, password, adminGroup, additionalInfo } = this.form.value;\r\n this.authenticationService.login(username!, password!, adminGroup, additionalInfo);\r\n }\r\n\r\n private authChangedHandler(authenticated: boolean): void {\r\n if (authenticated) {\r\n this.dialogRef.close();\r\n }\r\n }\r\n\r\n private errorHandler(err: any): void {\r\n console.log('Authentication error', err);\r\n this.errorMessage = `${err.name}: ${err.statusText}`;\r\n }\r\n\r\n changeTokenStorageMode(checked: boolean): void {\r\n const keyName = 'storeTokenInSession';\r\n\r\n if (checked) {\r\n if (localStorage.getItem(keyName)) {\r\n localStorage.removeItem(keyName);\r\n }\r\n } else {\r\n localStorage.setItem(keyName, 'true');\r\n }\r\n }\r\n}\r\n","<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\r\n <mat-slide-toggle *ngIf=\"authenticationService.config.showRememberMeOption\" [checked]=\"!authenticationService.useSessionStorage\" (change)=\"changeTokenStorageMode($event.checked)\">\r\n Remember me next time\r\n </mat-slide-toggle>\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>","import { Component, Input } from '@angular/core';\r\nimport { MatDialog } from '@angular/material/dialog';\r\nimport { ConfirmationComponent } from '@cleavelandprice/ngx-lib/dialog';\r\n\r\nimport { LoginFormComponent } from '../login-form/login-form.component';\r\nimport { AuthenticationService } from '../../services/authentication.service';\r\n\r\n@Component({\r\n selector: 'cp-login',\r\n templateUrl: './login.component.html',\r\n styleUrls: [\r\n './login.component.css',\r\n '../../../../../../styles/mat-icon.css'\r\n ]\r\n})\r\nexport class LoginComponent {\r\n @Input() adminGroup!: string;\r\n @Input() additionalInfo!: string;\r\n\r\n constructor(private dialog: MatDialog,\r\n public authenticationService: AuthenticationService) {\r\n }\r\n\r\n login(): void {\r\n this.dialog.open(LoginFormComponent, {\r\n data: {\r\n adminGroup: this.adminGroup,\r\n additionalInfo: this.additionalInfo\r\n }\r\n });\r\n }\r\n\r\n confirmLogout(): void {\r\n this.dialog.open(ConfirmationComponent, {\r\n data: { message: `Are you sure you want to logout?` }\r\n })\r\n .afterClosed()\r\n .subscribe(result => {\r\n if (result) {\r\n this.authenticationService.logout();\r\n }\r\n });\r\n }\r\n}\r\n","<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>","import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { ReactiveFormsModule } from '@angular/forms';\r\n\r\nimport { MatButtonModule } from '@angular/material/button';\r\nimport { MatDialogModule } from '@angular/material/dialog';\r\nimport { MatFormFieldModule } from '@angular/material/form-field';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { MatInputModule } from '@angular/material/input';\r\nimport { MatProgressSpinnerModule } from '@angular/material/progress-spinner';\r\nimport { MatSlideToggleModule } from '@angular/material/slide-toggle';\r\n\r\nimport { ServiceConfig } from './model/service-config';\r\n\r\nimport { AuthenticationService } from './services/authentication.service';\r\n\r\nimport { LoginComponent } from './components/login/login.component';\r\nimport { LoginFormComponent } from './components/login-form/login-form.component';\r\n\r\n@NgModule({\r\n declarations: [\r\n LoginComponent,\r\n LoginFormComponent\r\n ],\r\n imports: [\r\n CommonModule,\r\n ReactiveFormsModule,\r\n \r\n MatButtonModule,\r\n MatDialogModule,\r\n MatFormFieldModule,\r\n MatIconModule,\r\n MatInputModule,\r\n MatProgressSpinnerModule,\r\n MatSlideToggleModule\r\n ],\r\n exports: [\r\n LoginComponent,\r\n LoginFormComponent\r\n ]\r\n})\r\nexport class GuiModule {\r\n static forRoot(config: ServiceConfig): ModuleWithProviders<GuiModule> {\r\n return {\r\n ngModule: GuiModule,\r\n providers: [\r\n AuthenticationService,\r\n { provide: ServiceConfig, useValue: config }\r\n ]\r\n };\r\n }\r\n\r\n constructor(@Optional() @SkipSelf() parentModule: GuiModule) {\r\n if (parentModule) {\r\n throw new Error(\r\n 'GuiModule 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","TokenAuthenticationService","i1.ServiceConfig","i2.AuthenticationService","i3","i4"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAGM,MAAO,aAAc,SAAQA,eAAiB,CAAA;;AAEhD,IAAA,WAAA,CAAY,sBAA2C,GAAA,KAAK,EACjD,oBAAA,GAAuB,IAAI,EAClC,OAAA,GAA8B,SAAS,EACvC,SAAS,GAAG,OAAO,EACnB,oBAAoB,GAAG,qBAAqB,EAAA;QAE5C,KAAK,CAAC,sBAAsB,EAAE,OAAO,EAAE,SAAS,EAAE,oBAAoB,CA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;QACf,eAAe;QACf,kBAAkB;QAClB,aAAa;QACb,cAAc;QACd,wBAAwB;AACxB,QAAA,oBAAoB,aAGpB,cAAc;QACd,kBAAkB,CAAA,EAAA,CAAA,CAAA;AAGT,SAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,SAAS,YAhBlB,YAAY;QACZ,mBAAmB;QAEnB,eAAe;QACf,eAAe;QACf,kBAAkB;QAClB,aAAa;QACb,cAAc;QACd,wBAAwB;QACxB,oBAAoB,CAAA,EAAA,CAAA,CAAA;2FAOX,SAAS,EAAA,UAAA,EAAA,CAAA;kBAtBrB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE;wBACZ,cAAc;wBACd,kBAAkB;AACnB,qBAAA;AACD,oBAAA,OAAO,EAAE;wBACP,YAAY;wBACZ,mBAAmB;wBAEnB,eAAe;wBACf,eAAe;wBACf,kBAAkB;wBAClB,aAAa;wBACb,cAAc;wBACd,wBAAwB;wBACxB,oBAAoB;AACrB,qBAAA;AACD,oBAAA,OAAO,EAAE;wBACP,cAAc;wBACd,kBAAkB;AACnB,qBAAA;iBACF,CAAA;;;8BAYc,QAAQ;;8BAAI,QAAQ;;;;ACpDnC;;AAEG;;;;"}
|
|
@@ -8,8 +8,8 @@ import { CommonModule } from '@angular/common';
|
|
|
8
8
|
//import { ServiceConfig as NgxLibServiceConfig } from '@cleavelandprice/ngx-lib';
|
|
9
9
|
class ServiceConfig extends ServiceConfig$1 {
|
|
10
10
|
// See the comment in the library's main service-config.ts file for an explanation
|
|
11
|
-
constructor(useSsl_or_customApiUrl = false, tokenName = 'token', authenticateEndpoint = '/authenticate/token') {
|
|
12
|
-
super(useSsl_or_customApiUrl, tokenName, authenticateEndpoint);
|
|
11
|
+
constructor(useSsl_or_customApiUrl = false, appName = undefined, tokenName = 'token', authenticateEndpoint = '/authenticate/token') {
|
|
12
|
+
super(useSsl_or_customApiUrl, appName, tokenName, authenticateEndpoint);
|
|
13
13
|
this.deferTokenValidation = false;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -45,11 +45,13 @@ class AuthenticationService {
|
|
|
45
45
|
//#endregion
|
|
46
46
|
//#region Utilities
|
|
47
47
|
//Authenticate the user and store the token in Local Storage
|
|
48
|
-
login(username, password, adminGroup) {
|
|
48
|
+
login(username, password, adminGroup, additionalInfo) {
|
|
49
49
|
const request = {
|
|
50
|
-
username
|
|
51
|
-
password
|
|
52
|
-
adminGroup
|
|
50
|
+
username,
|
|
51
|
+
password,
|
|
52
|
+
adminGroup,
|
|
53
|
+
additionalInfo,
|
|
54
|
+
appName: this.config.appName
|
|
53
55
|
};
|
|
54
56
|
this.authenticating = true;
|
|
55
57
|
this.authenticatingChanged.emit(this.authenticating);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleavelandprice-ngx-lib-authentication-token.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/authentication/token/src/model/service-config.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/src/services/authentication.service.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/src/token.module.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/src/cleavelandprice-ngx-lib-authentication-token.ts"],"sourcesContent":["//import { ServiceConfig as NgxLibServiceConfig } from '@cleavelandprice/ngx-lib';\r\nimport { ServiceConfig as BaseServiceConfig } from '@cleavelandprice/ngx-lib/authentication';\r\n\r\nexport class ServiceConfig extends BaseServiceConfig {\r\n deferTokenValidation = false;\r\n \r\n // See the comment in the library's main service-config.ts file for an explanation\r\n constructor(useSsl_or_customApiUrl: boolean | string = false,\r\n tokenName = 'token',\r\n authenticateEndpoint = '/authenticate/token'\r\n ) {\r\n super(useSsl_or_customApiUrl, tokenName, authenticateEndpoint);\r\n }\r\n}","import { EventEmitter, Injectable, Optional, Output } from '@angular/core';\r\nimport { HttpClient } from '@angular/common/http';\r\nimport { JwtHelperService } from '@auth0/angular-jwt';\r\n\r\nimport {\r\n AbstractAuthenticationService,\r\n AuthenticatedUser,\r\n AuthenticationRequest\r\n} from '@cleavelandprice/ngx-lib/authentication';\r\n\r\nimport { AuthenticationToken } from '../model/authentication-token';\r\nimport { ServiceConfig } from '../model/service-config';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class AuthenticationService 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 | undefined; // Object representing the authenticated user\r\n //#endregion\r\n\r\n //#region Properties\r\n get useSessionStorage(): boolean {\r\n return !!localStorage.getItem('storeTokenInSession');\r\n }\r\n\r\n get storage(): Storage {\r\n return this.useSessionStorage ?\r\n sessionStorage:\r\n localStorage;\r\n }\r\n //#endregion\r\n\r\n //#region Lifecycle\r\n constructor(@Optional() protected config: ServiceConfig,\r\n protected http: HttpClient) {\r\n\r\n this.config = this.config ?? new ServiceConfig();\r\n\r\n if (!this.config.deferTokenValidation) {\r\n this.checkForExistingToken();\r\n }\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 // Sending a 'raw' POST request so that we can tell HttpClient that we are expecting text instead of Json\r\n // Otherwise, it would throw an error trying to decode Json from the response\r\n this.http.request('POST', `${this.config.apiUrl}${this.config.authenticateEndpoint}`, { body: request, responseType: 'text' })\r\n .subscribe({\r\n next: (token) => {\r\n if (token) {\r\n this.validateUser(token);\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 (this.storage.getItem(this.config.tokenName)) {\r\n this.storage.removeItem(this.config.tokenName);\r\n }\r\n\r\n this.authenticatedUser = undefined;\r\n this.authenticated = false;\r\n this.authenticatedChanged.emit(false);\r\n }\r\n \r\n validateUser(token: string): void {\r\n const jwtHelper = new JwtHelperService();\r\n const decoded = jwtHelper.decodeToken(token) as AuthenticationToken;\r\n\r\n if (jwtHelper.isTokenExpired(token)) {\r\n this.logout();\r\n return;\r\n }\r\n\r\n this.authenticatedUser = {\r\n admin: decoded.role === 'Admin',\r\n displayName: decoded.displayName,\r\n accountName: decoded.winaccountname,\r\n distinguishedName: decoded.distinguishedName,\r\n employeeNumber: decoded.employeeNumber,\r\n memberOf: decoded.memberOf\r\n };\r\n\r\n this.storage.setItem(this.config.tokenName, 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 = this.storage.getItem(this.config.tokenName);\r\n if (token) {\r\n this.validateUser(token);\r\n }\r\n }\r\n //#endregion\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 { AuthenticationService } from './services/authentication.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 TokenModule {\r\n static forRoot(config: ServiceConfig): ModuleWithProviders<TokenModule> {\r\n return {\r\n ngModule: TokenModule,\r\n providers: [\r\n AuthenticationService,\r\n { provide: ServiceConfig, useValue: config }\r\n ]\r\n };\r\n }\r\n\r\n constructor(@Optional() @SkipSelf() parentModule: TokenModule) {\r\n if (parentModule) {\r\n throw new Error(\r\n 'TokenModule 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":";;;;;;;AAAA;AAGM,MAAO,aAAc,SAAQA,eAAiB,CAAA;;IAIhD,WAAY,CAAA,sBAAA,GAA2C,KAAK,EACxD,SAAS,GAAG,OAAO,EACnB,oBAAoB,GAAG,qBAAqB,EAAA;AAE5C,QAAA,KAAK,CAAC,sBAAsB,EAAE,SAAS,EAAE,oBAAoB,CAAC,CAAC;AAPnE,QAAA,IAAoB,CAAA,oBAAA,GAAG,KAAK,CAAC;KAQ5B;AACJ;;MCGY,qBAAqB,CAAA;;;IAuBhC,WAAkC,CAAA,MAAqB,EACnC,IAAgB,EAAA;;AADF,QAAA,IAAM,CAAA,MAAA,GAAN,MAAM,CAAe;AACnC,QAAA,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAY;;AAtB1B,QAAA,IAAA,CAAA,oBAAoB,GAAG,IAAI,YAAY,EAAW,CAAC;AACnD,QAAA,IAAA,CAAA,qBAAqB,GAAG,IAAI,YAAY,EAAW,CAAC;AACpD,QAAA,IAAA,CAAA,mBAAmB,GAAG,IAAI,YAAY,EAAE,CAAC;AACnD,QAAA,IAAA,CAAA,cAAc,GAAG,KAAK,CAAC;AACvB,QAAA,IAAA,CAAA,aAAa,GAAG,KAAK,CAAC;QAoBV,IAAI,CAAC,MAAM,GAAG,CAAA,EAAA,GAAA,IAAI,CAAC,MAAM,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,IAAI,aAAa,EAAE,CAAC;AAEjD,QAAA,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE;YACrC,IAAI,CAAC,qBAAqB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;IAfD,OAAO,OAAO,CAAC,MAAqB,EAAA;QAClC,OAAO;AACL,YAAA,QAAQ,EAAE,WAAW;AACrB,YAAA,SAAS,EAAE;gBACT,qBAAqB;AACrB,gBAAA,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE;AAC7C,aAAA;SACF,CAAC;KACH;;wGATU,WAAW,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,WAAA,EAAA,QAAA,EAAA,IAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAAX,WAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAW,YAJpB,YAAY,CAAA,EAAA,CAAA,CAAA;AAIH,WAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAW,YAJpB,YAAY,CAAA,EAAA,CAAA,CAAA;2FAIH,WAAW,EAAA,UAAA,EAAA,CAAA;kBAPvB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;AACD,oBAAA,OAAO,EAAE,EAAE;iBACZ,CAAA;;;8BAYc,QAAQ;;8BAAI,QAAQ;;;;ACzBnC;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"cleavelandprice-ngx-lib-authentication-token.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/authentication/token/src/model/service-config.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/src/services/authentication.service.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/src/token.module.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/token/src/cleavelandprice-ngx-lib-authentication-token.ts"],"sourcesContent":["//import { ServiceConfig as NgxLibServiceConfig } from '@cleavelandprice/ngx-lib';\r\nimport { ServiceConfig as BaseServiceConfig } from '@cleavelandprice/ngx-lib/authentication';\r\n\r\nexport class ServiceConfig extends BaseServiceConfig {\r\n deferTokenValidation = false;\r\n \r\n // See the comment in the library's main service-config.ts file for an explanation\r\n constructor(useSsl_or_customApiUrl: boolean | string = false,\r\n appName: string | undefined = undefined,\r\n tokenName = 'token',\r\n authenticateEndpoint = '/authenticate/token'\r\n ) {\r\n super(useSsl_or_customApiUrl, appName, tokenName, authenticateEndpoint);\r\n }\r\n}","import { EventEmitter, Injectable, Optional, Output } from '@angular/core';\r\nimport { HttpClient } from '@angular/common/http';\r\nimport { JwtHelperService } from '@auth0/angular-jwt';\r\n\r\nimport {\r\n AbstractAuthenticationService,\r\n AuthenticatedUser,\r\n AuthenticationRequest\r\n} from '@cleavelandprice/ngx-lib/authentication';\r\n\r\nimport { AuthenticationToken } from '../model/authentication-token';\r\nimport { ServiceConfig } from '../model/service-config';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class AuthenticationService 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 | undefined; // Object representing the authenticated user\r\n //#endregion\r\n\r\n //#region Properties\r\n get useSessionStorage(): boolean {\r\n return !!localStorage.getItem('storeTokenInSession');\r\n }\r\n\r\n get storage(): Storage {\r\n return this.useSessionStorage ?\r\n sessionStorage:\r\n localStorage;\r\n }\r\n //#endregion\r\n\r\n //#region Lifecycle\r\n constructor(@Optional() protected config: ServiceConfig,\r\n protected http: HttpClient) {\r\n\r\n this.config = this.config ?? new ServiceConfig();\r\n\r\n if (!this.config.deferTokenValidation) {\r\n this.checkForExistingToken();\r\n }\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, additionalInfo?: string): void {\r\n const request: AuthenticationRequest = {\r\n username,\r\n password,\r\n adminGroup,\r\n additionalInfo,\r\n appName: this.config.appName\r\n };\r\n\r\n this.authenticating = true;\r\n this.authenticatingChanged.emit(this.authenticating);\r\n\r\n // Sending a 'raw' POST request so that we can tell HttpClient that we are expecting text instead of Json\r\n // Otherwise, it would throw an error trying to decode Json from the response\r\n this.http.request('POST', `${this.config.apiUrl}${this.config.authenticateEndpoint}`, { body: request, responseType: 'text' })\r\n .subscribe({\r\n next: (token) => {\r\n if (token) {\r\n this.validateUser(token);\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 (this.storage.getItem(this.config.tokenName)) {\r\n this.storage.removeItem(this.config.tokenName);\r\n }\r\n\r\n this.authenticatedUser = undefined;\r\n this.authenticated = false;\r\n this.authenticatedChanged.emit(false);\r\n }\r\n \r\n validateUser(token: string): void {\r\n const jwtHelper = new JwtHelperService();\r\n const decoded = jwtHelper.decodeToken(token) as AuthenticationToken;\r\n\r\n if (jwtHelper.isTokenExpired(token)) {\r\n this.logout();\r\n return;\r\n }\r\n\r\n this.authenticatedUser = {\r\n admin: decoded.role === 'Admin',\r\n displayName: decoded.displayName,\r\n accountName: decoded.winaccountname,\r\n distinguishedName: decoded.distinguishedName,\r\n employeeNumber: decoded.employeeNumber,\r\n memberOf: decoded.memberOf\r\n };\r\n\r\n this.storage.setItem(this.config.tokenName, 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 = this.storage.getItem(this.config.tokenName);\r\n if (token) {\r\n this.validateUser(token);\r\n }\r\n }\r\n //#endregion\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 { AuthenticationService } from './services/authentication.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 TokenModule {\r\n static forRoot(config: ServiceConfig): ModuleWithProviders<TokenModule> {\r\n return {\r\n ngModule: TokenModule,\r\n providers: [\r\n AuthenticationService,\r\n { provide: ServiceConfig, useValue: config }\r\n ]\r\n };\r\n }\r\n\r\n constructor(@Optional() @SkipSelf() parentModule: TokenModule) {\r\n if (parentModule) {\r\n throw new Error(\r\n 'TokenModule 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":";;;;;;;AAAA;AAGM,MAAO,aAAc,SAAQA,eAAiB,CAAA;;AAIhD,IAAA,WAAA,CAAY,sBAA2C,GAAA,KAAK,EACxD,OAAA,GAA8B,SAAS,EACvC,SAAS,GAAG,OAAO,EACnB,oBAAoB,GAAG,qBAAqB,EAAA;QAE5C,KAAK,CAAC,sBAAsB,EAAE,OAAO,EAAE,SAAS,EAAE,oBAAoB,CAAC,CAAC;AAR5E,QAAA,IAAoB,CAAA,oBAAA,GAAG,KAAK,CAAC;KAS5B;AACJ;;MCEY,qBAAqB,CAAA;;;IAuBhC,WAAkC,CAAA,MAAqB,EACnC,IAAgB,EAAA;;AADF,QAAA,IAAM,CAAA,MAAA,GAAN,MAAM,CAAe;AACnC,QAAA,IAAI,CAAA,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EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAW,YAJpB,YAAY,CAAA,EAAA,CAAA,CAAA;2FAIH,WAAW,EAAA,UAAA,EAAA,CAAA;kBAPvB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;AACD,oBAAA,OAAO,EAAE,EAAE;iBACZ,CAAA;;;8BAYc,QAAQ;;8BAAI,QAAQ;;;;ACzBnC;;AAEG;;;;"}
|
|
@@ -5,9 +5,10 @@ import { CommonModule } from '@angular/common';
|
|
|
5
5
|
|
|
6
6
|
class ServiceConfig extends ServiceConfig$1 {
|
|
7
7
|
// See the comment in the library's main service-config.ts file for an explanation
|
|
8
|
-
constructor(useSsl_or_customApiUrl = false, tokenName = 'token', // The name used as the Key of the item saved in the browser's LocalStorage
|
|
8
|
+
constructor(useSsl_or_customApiUrl = false, appName, tokenName = 'token', // The name used as the Key of the item saved in the browser's LocalStorage
|
|
9
9
|
authenticateEndpoint = '/authenticate/token') {
|
|
10
10
|
super(useSsl_or_customApiUrl);
|
|
11
|
+
this.appName = appName;
|
|
11
12
|
this.tokenName = tokenName;
|
|
12
13
|
this.authenticateEndpoint = authenticateEndpoint;
|
|
13
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleavelandprice-ngx-lib-authentication.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/authentication/src/model/service-config.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/src/authentication.base.module.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/src/cleavelandprice-ngx-lib-authentication.ts"],"sourcesContent":["import { ServiceConfig as NgxLibServiceConfig } from '@cleavelandprice/ngx-lib';\r\n\r\nexport class ServiceConfig extends NgxLibServiceConfig {\r\n // See the comment in the library's main service-config.ts file for an explanation\r\n constructor(useSsl_or_customApiUrl: boolean | string = false,\r\n public tokenName = 'token', // The name used as the Key of the item saved in the browser's LocalStorage\r\n public authenticateEndpoint = '/authenticate/token'\r\n ) {\r\n super(useSsl_or_customApiUrl);\r\n }\r\n}","import { NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\n\r\n@NgModule({\r\n declarations: [],\r\n imports: [\r\n CommonModule\r\n ],\r\n exports: []\r\n})\r\nexport class AuthenticationBaseModule {}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["NgxLibServiceConfig"],"mappings":";;;;;AAEM,MAAO,aAAc,SAAQA,eAAmB,CAAA;;IAElD,WAAY,CAAA,
|
|
1
|
+
{"version":3,"file":"cleavelandprice-ngx-lib-authentication.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/authentication/src/model/service-config.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/src/authentication.base.module.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/src/cleavelandprice-ngx-lib-authentication.ts"],"sourcesContent":["import { ServiceConfig as NgxLibServiceConfig } from '@cleavelandprice/ngx-lib';\r\n\r\nexport class ServiceConfig extends NgxLibServiceConfig {\r\n // See the comment in the library's main service-config.ts file for an explanation\r\n constructor(useSsl_or_customApiUrl: boolean | string = false,\r\n public appName: string | undefined,\r\n public tokenName = 'token', // The name used as the Key of the item saved in the browser's LocalStorage\r\n public authenticateEndpoint = '/authenticate/token'\r\n ) {\r\n super(useSsl_or_customApiUrl);\r\n }\r\n}","import { NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\n\r\n@NgModule({\r\n declarations: [],\r\n imports: [\r\n CommonModule\r\n ],\r\n exports: []\r\n})\r\nexport class AuthenticationBaseModule {}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["NgxLibServiceConfig"],"mappings":";;;;;AAEM,MAAO,aAAc,SAAQA,eAAmB,CAAA;;IAElD,WAAY,CAAA,sBAAA,GAA2C,KAAK,EACjD,OAA2B,EAC3B,SAAY,GAAA,OAAO;AACnB,IAAA,oBAAA,GAAuB,qBAAqB,EAAA;QAEnD,KAAK,CAAC,sBAAsB,CAAC,CAAC;AAJvB,QAAA,IAAO,CAAA,OAAA,GAAP,OAAO,CAAoB;AAC3B,QAAA,IAAS,CAAA,SAAA,GAAT,SAAS,CAAU;AACnB,QAAA,IAAoB,CAAA,oBAAA,GAApB,oBAAoB,CAAwB;KAGtD;AACJ;;MCDY,wBAAwB,CAAA;;qHAAxB,wBAAwB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAAxB,wBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,wBAAwB,YAJjC,YAAY,CAAA,EAAA,CAAA,CAAA;AAIH,wBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,wBAAwB,YAJjC,YAAY,CAAA,EAAA,CAAA,CAAA;2FAIH,wBAAwB,EAAA,UAAA,EAAA,CAAA;kBAPpC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;AACD,oBAAA,OAAO,EAAE,EAAE;iBACZ,CAAA;;;ACTD;;AAEG;;;;"}
|
|
@@ -248,3 +248,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImpor
|
|
|
248
248
|
|
|
249
249
|
export { BaseComponent, ChoiceComponent, ConfirmationComponent, ConfirmationDialogMode, DialogModule, DialogType, InputComponent, MessageComponent };
|
|
250
250
|
//# sourceMappingURL=cleavelandprice-ngx-lib-dialog.mjs.map
|
|
251
|
+
//# sourceMappingURL=cleavelandprice-ngx-lib-dialog.mjs.map
|
|
@@ -7,8 +7,8 @@ import { CommonModule } from '@angular/common';
|
|
|
7
7
|
//import { ServiceConfig as NgxLibServiceConfig } from '@cleavelandprice/ngx-lib';
|
|
8
8
|
class ServiceConfig extends ServiceConfig$1 {
|
|
9
9
|
// See the comment in the library's main service-config.ts file for an explanation
|
|
10
|
-
constructor(useSsl_or_customApiUrl = false, tokenName = 'user', authenticateEndpoint = '/authenticate') {
|
|
11
|
-
super(useSsl_or_customApiUrl, tokenName, authenticateEndpoint);
|
|
10
|
+
constructor(useSsl_or_customApiUrl = false, appName = undefined, tokenName = 'user', authenticateEndpoint = '/authenticate') {
|
|
11
|
+
super(useSsl_or_customApiUrl, appName, tokenName, authenticateEndpoint);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -40,11 +40,13 @@ class AuthenticationService {
|
|
|
40
40
|
//#endregion
|
|
41
41
|
//#region Utilities
|
|
42
42
|
//Authenticate the user and store the token in Local Storage
|
|
43
|
-
login(username, password, adminGroup) {
|
|
43
|
+
login(username, password, adminGroup, additionalInfo) {
|
|
44
44
|
const request = {
|
|
45
|
-
username
|
|
46
|
-
password
|
|
47
|
-
adminGroup
|
|
45
|
+
username,
|
|
46
|
+
password,
|
|
47
|
+
adminGroup,
|
|
48
|
+
additionalInfo,
|
|
49
|
+
appName: this.config.appName
|
|
48
50
|
};
|
|
49
51
|
this.authenticating = true;
|
|
50
52
|
this.authenticatingChanged.emit(this.authenticating);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleavelandprice-ngx-lib-authentication-object.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/authentication/object/src/model/service-config.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/object/src/services/authentication.service.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/object/src/object.module.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/object/src/cleavelandprice-ngx-lib-authentication-object.ts"],"sourcesContent":["//import { ServiceConfig as NgxLibServiceConfig } from '@cleavelandprice/ngx-lib';\r\nimport { ServiceConfig as BaseServiceConfig } from '@cleavelandprice/ngx-lib/authentication';\r\n\r\nexport class ServiceConfig extends BaseServiceConfig {\r\n \r\n // See the comment in the library's main service-config.ts file for an explanation\r\n constructor(useSsl_or_customApiUrl: boolean | string = false,\r\n tokenName = 'user',\r\n authenticateEndpoint = '/authenticate'\r\n ) {\r\n super(useSsl_or_customApiUrl, tokenName, authenticateEndpoint);\r\n }\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 { ServiceConfig } from '../model/service-config';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class AuthenticationService 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 | undefined; // Object representing the authenticated user\r\n //#endregion\r\n\r\n //#region Properties\r\n get useSessionStorage(): boolean {\r\n return !!localStorage.getItem('storeTokenInSession');\r\n }\r\n\r\n get storage(): Storage {\r\n return this.useSessionStorage ?\r\n sessionStorage:\r\n localStorage;\r\n }\r\n //#endregion\r\n\r\n //#region Lifecycle\r\n constructor(@Optional() private config: ServiceConfig,\r\n private http: HttpClient) {\r\n\r\n this.config = this.config ?? new ServiceConfig();\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}${this.config.authenticateEndpoint}`, 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 (this.storage.getItem(this.config.tokenName)) {\r\n this.storage.removeItem(this.config.tokenName);\r\n }\r\n\r\n this.authenticatedUser = undefined;\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 this.storage.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 = this.storage.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 { AuthenticationService } from './services/authentication.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 ObjectModule {\r\n static forRoot(config: ServiceConfig): ModuleWithProviders<ObjectModule> {\r\n return {\r\n ngModule: ObjectModule,\r\n providers: [\r\n AuthenticationService,\r\n { provide: ServiceConfig, useValue: config }\r\n ]\r\n };\r\n }\r\n\r\n constructor(@Optional() @SkipSelf() parentModule: ObjectModule) {\r\n if (parentModule) {\r\n throw new Error(\r\n 'ObjectModule 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":";;;;;;AAAA;AAGM,MAAO,aAAc,SAAQA,eAAiB,CAAA;;IAGhD,WAAY,CAAA,sBAAA,GAA2C,KAAK,EACxD,SAAS,GAAG,MAAM,EAClB,oBAAoB,GAAG,eAAe,EAAA;AAEtC,QAAA,KAAK,CAAC,sBAAsB,EAAE,SAAS,EAAE,oBAAoB,CAAC,CAAC;KAClE;AACJ;;MCIY,qBAAqB,CAAA;;;IAuB9B,WAAgC,CAAA,MAAqB,EACnC,IAAgB,EAAA;QADF,IAAM,CAAA,MAAA,GAAN,MAAM,CAAe;QACnC,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAY;;AAtB1B,QAAA,IAAA,CAAA,oBAAoB,GAAG,IAAI,YAAY,EAAW,CAAC;AACnD,QAAA,IAAA,CAAA,qBAAqB,GAAG,IAAI,YAAY,EAAW,CAAC;AACpD,QAAA,IAAA,CAAA,mBAAmB,GAAG,IAAI,YAAY,EAAE,CAAC;AACnD,QAAA,IAAA,CAAA,cAAc,GAAG,KAAK,CAAC;AACvB,QAAA,IAAA,CAAA,aAAa,GAAG,KAAK,CAAC;QAoBR,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;QAEjD,IAAI,CAAC,qBAAqB,EAAE,CAAC;KAC1C;;;AAlBD,IAAA,IA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,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAAZ,YAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,YAJrB,YAAY,CAAA,EAAA,CAAA,CAAA;AAIH,YAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,YAJrB,YAAY,CAAA,EAAA,CAAA,CAAA;2FAIH,YAAY,EAAA,UAAA,EAAA,CAAA;kBAPxB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;AACD,oBAAA,OAAO,EAAE,EAAE;AACZ,iBAAA,CAAA;;0BAYc,QAAQ;;0BAAI,QAAQ;;;ACzBnC;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"cleavelandprice-ngx-lib-authentication-object.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/authentication/object/src/model/service-config.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/object/src/services/authentication.service.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/object/src/object.module.ts","../../../../projects/cleavelandprice/ngx-lib/authentication/object/src/cleavelandprice-ngx-lib-authentication-object.ts"],"sourcesContent":["//import { ServiceConfig as NgxLibServiceConfig } from '@cleavelandprice/ngx-lib';\r\nimport { ServiceConfig as BaseServiceConfig } from '@cleavelandprice/ngx-lib/authentication';\r\n\r\nexport class ServiceConfig extends BaseServiceConfig {\r\n \r\n // See the comment in the library's main service-config.ts file for an explanation\r\n constructor(useSsl_or_customApiUrl: boolean | string = false,\r\n appName: string | undefined = undefined,\r\n tokenName = 'user',\r\n authenticateEndpoint = '/authenticate'\r\n ) {\r\n super(useSsl_or_customApiUrl, appName, tokenName, authenticateEndpoint);\r\n }\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 { ServiceConfig } from '../model/service-config';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class AuthenticationService 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 | undefined; // Object representing the authenticated user\r\n //#endregion\r\n\r\n //#region Properties\r\n get useSessionStorage(): boolean {\r\n return !!localStorage.getItem('storeTokenInSession');\r\n }\r\n\r\n get storage(): Storage {\r\n return this.useSessionStorage ?\r\n sessionStorage:\r\n localStorage;\r\n }\r\n //#endregion\r\n\r\n //#region Lifecycle\r\n constructor(@Optional() private config: ServiceConfig,\r\n private http: HttpClient) {\r\n\r\n this.config = this.config ?? new ServiceConfig();\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, additionalInfo?: string): void {\r\n const request: AuthenticationRequest = {\r\n username,\r\n password,\r\n adminGroup,\r\n additionalInfo,\r\n appName: this.config.appName\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}${this.config.authenticateEndpoint}`, 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 (this.storage.getItem(this.config.tokenName)) {\r\n this.storage.removeItem(this.config.tokenName);\r\n }\r\n\r\n this.authenticatedUser = undefined;\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 this.storage.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 = this.storage.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 { AuthenticationService } from './services/authentication.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 ObjectModule {\r\n static forRoot(config: ServiceConfig): ModuleWithProviders<ObjectModule> {\r\n return {\r\n ngModule: ObjectModule,\r\n providers: [\r\n AuthenticationService,\r\n { provide: ServiceConfig, useValue: config }\r\n ]\r\n };\r\n }\r\n\r\n constructor(@Optional() @SkipSelf() parentModule: ObjectModule) {\r\n if (parentModule) {\r\n throw new Error(\r\n 'ObjectModule 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":";;;;;;AAAA;AAGM,MAAO,aAAc,SAAQA,eAAiB,CAAA;;AAGhD,IAAA,WAAA,CAAY,sBAA2C,GAAA,KAAK,EACxD,OAAA,GAA8B,SAAS,EACvC,SAAS,GAAG,MAAM,EAClB,oBAAoB,GAAG,eAAe,EAAA;QAEtC,KAAK,CAAC,sBAAsB,EAAE,OAAO,EAAE,SAAS,EAAE,oBAAoB,CAAC,CAAC;KAC3E;AACJ;;MCGY,qBAAqB,CAAA;;;IAuB9B,WAAgC,CAAA,MAAqB,EACnC,IAAgB,EAAA;QADF,IAAM,CAAA,MAAA,GAAN,MAAM,CAAe;QACnC,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAY;;AAtB1B,QAAA,IAAA,CAAA,oBAAoB,GAAG,IAAI,YAAY,EAAW,CAAC;AACnD,QAAA,IAAA,CAAA,qBAAqB,GAAG,IAAI,YAAY,EAAW,CAAC;AACpD,QAAA,IAAA,CAAA,mBAAmB,GAAG,IAAI,YAAY,EAAE,CAAC;AACnD,QAAA,IAAA,CAAA,cAAc,GAAG,KAAK,CAAC;AACvB,QAAA,IAAA,CAAA,aAAa,GAAG,KAAK,CAAC;QAoBR,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;QAEjD,IAAI,CAAC,qBAAqB,EAAE,CAAC;KAC1C;;;AAlBD,IAAA,IAAI,iBAAiB,GAAA;QACnB,OAAO,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;KACtD;AAED,IAAA,IAAI,OAAO,GAAA;AACT,QAAA,OAAO,IAAI,CAAC,iBAAiB;AAC3B,YAAA,cAA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A,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,YAJrB,YAAY,CAAA,EAAA,CAAA,CAAA;AAIH,YAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,YAJrB,YAAY,CAAA,EAAA,CAAA,CAAA;2FAIH,YAAY,EAAA,UAAA,EAAA,CAAA;kBAPxB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;AACD,oBAAA,OAAO,EAAE,EAAE;AACZ,iBAAA,CAAA;;0BAYc,QAAQ;;0BAAI,QAAQ;;;ACzBnC;;AAEG;;;;"}
|
|
@@ -27,8 +27,8 @@ import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
|
|
27
27
|
//import { ServiceConfig as NgxLibServiceConfig } from '@cleavelandprice/ngx-lib';
|
|
28
28
|
class ServiceConfig extends ServiceConfig$1 {
|
|
29
29
|
// See the comment in the library's main service-config.ts file for an explanation
|
|
30
|
-
constructor(useSsl_or_customApiUrl = false, showRememberMeOption = true, tokenName = 'token', authenticateEndpoint = '/authenticate/token') {
|
|
31
|
-
super(useSsl_or_customApiUrl, tokenName, authenticateEndpoint);
|
|
30
|
+
constructor(useSsl_or_customApiUrl = false, showRememberMeOption = true, appName = undefined, tokenName = 'token', authenticateEndpoint = '/authenticate/token') {
|
|
31
|
+
super(useSsl_or_customApiUrl, appName, tokenName, authenticateEndpoint);
|
|
32
32
|
this.showRememberMeOption = showRememberMeOption;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -110,9 +110,11 @@ class LoginFormComponent {
|
|
|
110
110
|
this.form = new FormGroup({
|
|
111
111
|
username: new FormControl(null, [Validators.required]),
|
|
112
112
|
password: new FormControl(null, [Validators.required]),
|
|
113
|
-
adminGroup: new FormControl()
|
|
113
|
+
adminGroup: new FormControl(),
|
|
114
|
+
additionalInfo: new FormControl()
|
|
114
115
|
});
|
|
115
116
|
this.form.get('adminGroup')?.setValue(data.adminGroup);
|
|
117
|
+
this.form.get('additionalInfo')?.setValue(data.additionalInfo);
|
|
116
118
|
}
|
|
117
119
|
ngOnInit() {
|
|
118
120
|
this.authenticatedChangedSubscription = this.authenticationService.authenticatedChanged
|
|
@@ -126,8 +128,8 @@ class LoginFormComponent {
|
|
|
126
128
|
}
|
|
127
129
|
authenticate() {
|
|
128
130
|
this.errorMessage = undefined;
|
|
129
|
-
const { username, password, adminGroup } = this.form.value;
|
|
130
|
-
this.authenticationService.login(username, password, adminGroup);
|
|
131
|
+
const { username, password, adminGroup, additionalInfo } = this.form.value;
|
|
132
|
+
this.authenticationService.login(username, password, adminGroup, additionalInfo);
|
|
131
133
|
}
|
|
132
134
|
authChangedHandler(authenticated) {
|
|
133
135
|
if (authenticated) {
|
|
@@ -167,7 +169,10 @@ class LoginComponent {
|
|
|
167
169
|
}
|
|
168
170
|
login() {
|
|
169
171
|
this.dialog.open(LoginFormComponent, {
|
|
170
|
-
data: {
|
|
172
|
+
data: {
|
|
173
|
+
adminGroup: this.adminGroup,
|
|
174
|
+
additionalInfo: this.additionalInfo
|
|
175
|
+
}
|
|
171
176
|
});
|
|
172
177
|
}
|
|
173
178
|
confirmLogout() {
|
|
@@ -183,12 +188,14 @@ class LoginComponent {
|
|
|
183
188
|
}
|
|
184
189
|
}
|
|
185
190
|
LoginComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: LoginComponent, deps: [{ token: i1.MatDialog }, { token: AuthenticationService }], target: i0.ɵɵFactoryTarget.Component });
|
|
186
|
-
LoginComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", type: LoginComponent, selector: "cp-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"] }] });
|
|
191
|
+
LoginComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", type: LoginComponent, selector: "cp-login", inputs: { adminGroup: "adminGroup", additionalInfo: "additionalInfo" }, 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"] }] });
|
|
187
192
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: LoginComponent, decorators: [{
|
|
188
193
|
type: Component,
|
|
189
194
|
args: [{ selector: 'cp-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"] }]
|
|
190
195
|
}], ctorParameters: function () { return [{ type: i1.MatDialog }, { type: AuthenticationService }]; }, propDecorators: { adminGroup: [{
|
|
191
196
|
type: Input
|
|
197
|
+
}], additionalInfo: [{
|
|
198
|
+
type: Input
|
|
192
199
|
}] } });
|
|
193
200
|
|
|
194
201
|
class GuiModule {
|