@trudb/tru-common-lib 0.0.357 → 0.0.360
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/esm2020/lib/components/login/classes/tru-auth-session-strategy.mjs +28 -0
- package/esm2020/lib/components/login/classes/tru-auth-strategy-provider.mjs +19 -0
- package/esm2020/lib/components/login/services/tru-auth.mjs +12 -9
- package/esm2020/lib/components/login/tru-login-module.mjs +36 -10
- package/esm2020/lib/components/login/tru-login.mjs +2 -5
- package/esm2020/public-api.mjs +2 -1
- package/fesm2015/trudb-tru-common-lib.mjs +89 -28
- package/fesm2015/trudb-tru-common-lib.mjs.map +1 -1
- package/fesm2020/trudb-tru-common-lib.mjs +89 -28
- package/fesm2020/trudb-tru-common-lib.mjs.map +1 -1
- package/lib/components/login/classes/tru-auth-session-strategy.d.ts +13 -0
- package/lib/components/login/classes/tru-auth-strategy-provider.d.ts +8 -0
- package/lib/components/login/services/tru-auth.d.ts +4 -2
- package/lib/components/login/tru-login-module.d.ts +2 -1
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
|
@@ -11,7 +11,7 @@ import moment from 'moment/moment';
|
|
|
11
11
|
import * as i1 from '@angular/material/dialog';
|
|
12
12
|
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
|
|
13
13
|
import * as i1$2 from '@angular/common/http';
|
|
14
|
-
import { HttpClientModule } from '@angular/common/http';
|
|
14
|
+
import { HttpClientModule, HttpClient, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
15
15
|
import * as i3 from '@angular/material/checkbox';
|
|
16
16
|
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
17
17
|
import * as i1$1 from 'ngx-toastr';
|
|
@@ -33,6 +33,7 @@ import { BrowserModule } from '@angular/platform-browser';
|
|
|
33
33
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
34
34
|
import { tap, map, catchError } from 'rxjs/operators';
|
|
35
35
|
import * as i1$5 from '@angular/router';
|
|
36
|
+
import { RouterModule } from '@angular/router';
|
|
36
37
|
import * as i4 from '@angular/material/card';
|
|
37
38
|
import { MatCardModule } from '@angular/material/card';
|
|
38
39
|
import { A11yModule } from '@angular/cdk/a11y';
|
|
@@ -4508,17 +4509,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImpor
|
|
|
4508
4509
|
}] });
|
|
4509
4510
|
|
|
4510
4511
|
class TruAuth {
|
|
4511
|
-
constructor(router, http, cache, auth) {
|
|
4512
|
+
constructor(router, http, cache, environment, auth) {
|
|
4512
4513
|
this.router = router;
|
|
4513
4514
|
this.http = http;
|
|
4514
4515
|
this.cache = cache;
|
|
4516
|
+
this.environment = environment;
|
|
4515
4517
|
this.auth = auth;
|
|
4516
4518
|
this.loggedIn = new BehaviorSubject(false);
|
|
4517
|
-
this.baseUrl =
|
|
4519
|
+
this.baseUrl = '';
|
|
4520
|
+
if (location.hostname === 'localhost' || location.hostname === '127.0.0.1' || location.hostname === '')
|
|
4521
|
+
this.baseUrl = 'https://localhost:44303';
|
|
4522
|
+
else
|
|
4523
|
+
this.baseUrl = '';
|
|
4518
4524
|
}
|
|
4519
4525
|
login(loginRequest) {
|
|
4520
4526
|
return this.http
|
|
4521
|
-
//.post<any>(this.baseUrl + "/auth/Login", loginRequest)
|
|
4522
4527
|
.post(`${this.baseUrl}${TRU_AUTH_CONFIG.authUrl}/login`, loginRequest)
|
|
4523
4528
|
.pipe(tap((data) => {
|
|
4524
4529
|
this.auth.doLoginUser(data);
|
|
@@ -4529,9 +4534,7 @@ class TruAuth {
|
|
|
4529
4534
|
this.doLogoutUser();
|
|
4530
4535
|
}
|
|
4531
4536
|
isLoggedIn$() {
|
|
4532
|
-
return this.auth.getCurrentUser().pipe(map(() => true),
|
|
4533
|
-
//map((user) => !!user),
|
|
4534
|
-
catchError(() => of(false)));
|
|
4537
|
+
return this.auth.getCurrentUser().pipe(map(() => true), catchError(() => of(false)));
|
|
4535
4538
|
}
|
|
4536
4539
|
get isLoggedIn() {
|
|
4537
4540
|
if (!this.loggedIn.value) {
|
|
@@ -4551,14 +4554,14 @@ class TruAuth {
|
|
|
4551
4554
|
this.auth.doLogoutUser();
|
|
4552
4555
|
}
|
|
4553
4556
|
}
|
|
4554
|
-
TruAuth.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruAuth, deps: [{ token: i1$5.Router }, { token: i1$2.HttpClient }, { token: TruAuthCache }, { token: TRU_AUTH_STRATEGY }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4557
|
+
TruAuth.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruAuth, deps: [{ token: i1$5.Router }, { token: i1$2.HttpClient }, { token: TruAuthCache }, { token: TruAppEnvironment }, { token: TRU_AUTH_STRATEGY }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4555
4558
|
TruAuth.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruAuth, providedIn: "root" });
|
|
4556
4559
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruAuth, decorators: [{
|
|
4557
4560
|
type: Injectable,
|
|
4558
4561
|
args: [{
|
|
4559
4562
|
providedIn: "root",
|
|
4560
4563
|
}]
|
|
4561
|
-
}], ctorParameters: function () { return [{ type: i1$5.Router }, { type: i1$2.HttpClient }, { type: TruAuthCache }, { type: undefined, decorators: [{
|
|
4564
|
+
}], ctorParameters: function () { return [{ type: i1$5.Router }, { type: i1$2.HttpClient }, { type: TruAuthCache }, { type: TruAppEnvironment }, { type: undefined, decorators: [{
|
|
4562
4565
|
type: Inject,
|
|
4563
4566
|
args: [TRU_AUTH_STRATEGY]
|
|
4564
4567
|
}] }]; } });
|
|
@@ -4576,7 +4579,6 @@ class TruLogin {
|
|
|
4576
4579
|
return this.loginForm.controls;
|
|
4577
4580
|
}
|
|
4578
4581
|
onSubmit() {
|
|
4579
|
-
//create a new login request
|
|
4580
4582
|
const loginRequest = {
|
|
4581
4583
|
username: this.f.username.value,
|
|
4582
4584
|
password: this.f.password.value
|
|
@@ -4586,9 +4588,7 @@ class TruLogin {
|
|
|
4586
4588
|
.login(loginRequest)
|
|
4587
4589
|
.subscribe((user) => [
|
|
4588
4590
|
//this.router.navigate(...) where to?
|
|
4589
|
-
]
|
|
4590
|
-
//if there is a login error
|
|
4591
|
-
, (error) => {
|
|
4591
|
+
], (error) => {
|
|
4592
4592
|
if (error.status === 401) {
|
|
4593
4593
|
this.loginError = "Incorrect username and/or password";
|
|
4594
4594
|
}
|
|
@@ -4753,20 +4753,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImpor
|
|
|
4753
4753
|
}]
|
|
4754
4754
|
}] });
|
|
4755
4755
|
|
|
4756
|
-
class TruLoginModule {
|
|
4757
|
-
}
|
|
4758
|
-
TruLoginModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruLoginModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
4759
|
-
TruLoginModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.1", ngImport: i0, type: TruLoginModule, declarations: [TruLogin], imports: [CommonModule, MaterialModule, FormsModule, ReactiveFormsModule], exports: [TruLogin] });
|
|
4760
|
-
TruLoginModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruLoginModule, imports: [CommonModule, MaterialModule, FormsModule, ReactiveFormsModule] });
|
|
4761
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruLoginModule, decorators: [{
|
|
4762
|
-
type: NgModule,
|
|
4763
|
-
args: [{
|
|
4764
|
-
declarations: [TruLogin],
|
|
4765
|
-
imports: [CommonModule, MaterialModule, FormsModule, ReactiveFormsModule,],
|
|
4766
|
-
exports: [TruLogin]
|
|
4767
|
-
}]
|
|
4768
|
-
}] });
|
|
4769
|
-
|
|
4770
4756
|
class TruAuthJwtStrategy {
|
|
4771
4757
|
constructor() {
|
|
4772
4758
|
this.JWT_TOKEN = "JWT_TOKEN";
|
|
@@ -4837,6 +4823,81 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImpor
|
|
|
4837
4823
|
args: [TRU_AUTH_STRATEGY]
|
|
4838
4824
|
}] }]; } });
|
|
4839
4825
|
|
|
4826
|
+
class TruAuthSessionStrategy {
|
|
4827
|
+
constructor(http) {
|
|
4828
|
+
this.http = http;
|
|
4829
|
+
}
|
|
4830
|
+
doLoginUser(user) {
|
|
4831
|
+
this.loggedUser = user;
|
|
4832
|
+
}
|
|
4833
|
+
doLogoutUser() {
|
|
4834
|
+
this.loggedUser = undefined;
|
|
4835
|
+
}
|
|
4836
|
+
getCurrentUser() {
|
|
4837
|
+
if (this.loggedUser) {
|
|
4838
|
+
return of(this.loggedUser);
|
|
4839
|
+
}
|
|
4840
|
+
else {
|
|
4841
|
+
return this.http
|
|
4842
|
+
.get(`${TRU_AUTH_CONFIG.authUrl}/user`)
|
|
4843
|
+
.pipe(tap((user) => (this.loggedUser = user)));
|
|
4844
|
+
}
|
|
4845
|
+
}
|
|
4846
|
+
isLoggedIn() {
|
|
4847
|
+
return false; //todo, implement this
|
|
4848
|
+
}
|
|
4849
|
+
}
|
|
4850
|
+
|
|
4851
|
+
const TruAuthStrategyProvider = {
|
|
4852
|
+
provide: TRU_AUTH_STRATEGY,
|
|
4853
|
+
deps: [HttpClient],
|
|
4854
|
+
useFactory: (http) => {
|
|
4855
|
+
switch (TRU_AUTH_CONFIG.auth) {
|
|
4856
|
+
case "session":
|
|
4857
|
+
return new TruAuthSessionStrategy(http);
|
|
4858
|
+
case "token":
|
|
4859
|
+
return new TruAuthJwtStrategy();
|
|
4860
|
+
default:
|
|
4861
|
+
throw new Error("Invalid auth strategy");
|
|
4862
|
+
}
|
|
4863
|
+
},
|
|
4864
|
+
};
|
|
4865
|
+
|
|
4866
|
+
const routes = [
|
|
4867
|
+
{
|
|
4868
|
+
path: 'login',
|
|
4869
|
+
component: TruLogin
|
|
4870
|
+
}
|
|
4871
|
+
];
|
|
4872
|
+
class TruLoginModule {
|
|
4873
|
+
}
|
|
4874
|
+
TruLoginModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruLoginModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
4875
|
+
TruLoginModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.1", ngImport: i0, type: TruLoginModule, declarations: [TruLogin], imports: [CommonModule, MaterialModule, FormsModule, ReactiveFormsModule, i1$5.RouterModule], exports: [TruLogin] });
|
|
4876
|
+
TruLoginModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruLoginModule, providers: [
|
|
4877
|
+
{
|
|
4878
|
+
provide: HTTP_INTERCEPTORS,
|
|
4879
|
+
useClass: TruAuthInterceptor,
|
|
4880
|
+
multi: true,
|
|
4881
|
+
},
|
|
4882
|
+
TruAuthStrategyProvider
|
|
4883
|
+
], imports: [CommonModule, MaterialModule, FormsModule, ReactiveFormsModule, RouterModule.forChild(routes)] });
|
|
4884
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: TruLoginModule, decorators: [{
|
|
4885
|
+
type: NgModule,
|
|
4886
|
+
args: [{
|
|
4887
|
+
declarations: [TruLogin],
|
|
4888
|
+
imports: [CommonModule, MaterialModule, FormsModule, ReactiveFormsModule, RouterModule.forChild(routes)],
|
|
4889
|
+
exports: [TruLogin],
|
|
4890
|
+
providers: [
|
|
4891
|
+
{
|
|
4892
|
+
provide: HTTP_INTERCEPTORS,
|
|
4893
|
+
useClass: TruAuthInterceptor,
|
|
4894
|
+
multi: true,
|
|
4895
|
+
},
|
|
4896
|
+
TruAuthStrategyProvider
|
|
4897
|
+
],
|
|
4898
|
+
}]
|
|
4899
|
+
}] });
|
|
4900
|
+
|
|
4840
4901
|
class TruValidationDialog {
|
|
4841
4902
|
constructor(renderer, elementRef, util) {
|
|
4842
4903
|
this.renderer = renderer;
|
|
@@ -5623,5 +5684,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImpor
|
|
|
5623
5684
|
* Generated bundle index. Do not edit.
|
|
5624
5685
|
*/
|
|
5625
5686
|
|
|
5626
|
-
export { DetailViewModule, TruAppEnvironment, TruAuthInterceptor, TruBreezeContext, TruBreezeContextFactory, TruBreezeMetadataProvider, TruBreezeValidator, TruBreezeValidatorModule, TruChoice, TruColumn, TruColumnModule, TruCommonModule, TruComponentConfigBase, TruComponentLookup, TruConfirmDialog, TruConfirmDialogConfig, TruConfirmDialogModule, TruContextFilter, TruContextFilterChoice, TruContextFilters, TruControlComponentConfigBase, TruDataContext, TruDataGrid, TruDataGridModule, TruDataGridTypes, TruDesktop, TruDesktopManager, TruDesktopModule, TruDetailViewBase, TruEditControlBase, TruEditControlConfigBase, TruEntityAccessor, TruEntityBase, TruExportDialog, TruExportDialogConfig, TruExportDialogModule, TruForm, TruFormModule, TruFormulaEval, TruGroupBox, TruGroupBoxModule, TruIconModule, TruLogin, TruLoginModule, TruPredicate, TruPredicateMap, TruPropertyConfigBase, TruPropertyConfigCloudFile, TruPropertyConfigDate, TruPropertyConfigDecimal, TruPropertyConfigFile, TruPropertyConfigForeignKey, TruPropertyConfigInteger, TruPropertyConfigPassword, TruPropertyConfigPercentage, TruPropertyConfigScientific, TruPropertyConfigText, TruPropertyConfigTextChoices, TruPropertyConfigUsaAddress, TruPropertyConfigZipCode, TruQueryPredicateManager, TruRow, TruRowModule, TruSearchConfigBase, TruSearchControlBase, TruSearchControlConfigBase, TruSearchControlRangeBase, TruSearchIconModule, TruSearchPanelPositionManager, TruSearchPanelPositionManagerModule, TruSearchViewBase, TruSearchViewBaseModule, TruSearchViewControlEventHandler, TruSearchViewEventHandler, TruSort, TruTableConfigBase, TruTableRegistry, TruTextManager, TruToolbar, TruToolbarButton, TruToolbarButtonModule, TruToolbarContextFilter, TruToolbarContextFilterModule, TruToolbarDropdown, TruToolbarDropdownModule, TruToolbarMenu, TruToolbarMenuModule, TruToolbarModule, TruToolbarSeparator, TruToolbarSeparatorModule, TruToolbarText, TruToolbarTextModule, TruUiNotification, TruUser, TruUtil, TruValidationDialog, TruValidationDialogModule, TruWindowActionEventHandler, TruWindowAddViewEventArgs, TruWindowEventArgs, TruWindowEventHandler };
|
|
5687
|
+
export { DetailViewModule, TruAppEnvironment, TruAuth, TruAuthInterceptor, TruBreezeContext, TruBreezeContextFactory, TruBreezeMetadataProvider, TruBreezeValidator, TruBreezeValidatorModule, TruChoice, TruColumn, TruColumnModule, TruCommonModule, TruComponentConfigBase, TruComponentLookup, TruConfirmDialog, TruConfirmDialogConfig, TruConfirmDialogModule, TruContextFilter, TruContextFilterChoice, TruContextFilters, TruControlComponentConfigBase, TruDataContext, TruDataGrid, TruDataGridModule, TruDataGridTypes, TruDesktop, TruDesktopManager, TruDesktopModule, TruDetailViewBase, TruEditControlBase, TruEditControlConfigBase, TruEntityAccessor, TruEntityBase, TruExportDialog, TruExportDialogConfig, TruExportDialogModule, TruForm, TruFormModule, TruFormulaEval, TruGroupBox, TruGroupBoxModule, TruIconModule, TruLogin, TruLoginModule, TruPredicate, TruPredicateMap, TruPropertyConfigBase, TruPropertyConfigCloudFile, TruPropertyConfigDate, TruPropertyConfigDecimal, TruPropertyConfigFile, TruPropertyConfigForeignKey, TruPropertyConfigInteger, TruPropertyConfigPassword, TruPropertyConfigPercentage, TruPropertyConfigScientific, TruPropertyConfigText, TruPropertyConfigTextChoices, TruPropertyConfigUsaAddress, TruPropertyConfigZipCode, TruQueryPredicateManager, TruRow, TruRowModule, TruSearchConfigBase, TruSearchControlBase, TruSearchControlConfigBase, TruSearchControlRangeBase, TruSearchIconModule, TruSearchPanelPositionManager, TruSearchPanelPositionManagerModule, TruSearchViewBase, TruSearchViewBaseModule, TruSearchViewControlEventHandler, TruSearchViewEventHandler, TruSort, TruTableConfigBase, TruTableRegistry, TruTextManager, TruToolbar, TruToolbarButton, TruToolbarButtonModule, TruToolbarContextFilter, TruToolbarContextFilterModule, TruToolbarDropdown, TruToolbarDropdownModule, TruToolbarMenu, TruToolbarMenuModule, TruToolbarModule, TruToolbarSeparator, TruToolbarSeparatorModule, TruToolbarText, TruToolbarTextModule, TruUiNotification, TruUser, TruUtil, TruValidationDialog, TruValidationDialogModule, TruWindowActionEventHandler, TruWindowAddViewEventArgs, TruWindowEventArgs, TruWindowEventHandler };
|
|
5627
5688
|
//# sourceMappingURL=trudb-tru-common-lib.mjs.map
|