@flusys/ng-auth 6.2.1 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,7 +5,7 @@ import { APP_CONFIG, getServiceUrl, isCompanyFeatureEnabled, isServiceEnabled, i
|
|
|
5
5
|
import { of, timeout, switchMap, map, tap, catchError, shareReplay, finalize, BehaviorSubject, throwError, filter, take, from, forkJoin, firstValueFrom } from 'rxjs';
|
|
6
6
|
import * as i2 from '@angular/router';
|
|
7
7
|
import { Router, RouterOutlet, ActivatedRoute } from '@angular/router';
|
|
8
|
-
import { PlatformService, TranslateService, ApiResourceService, CookieService,
|
|
8
|
+
import { PlatformService, TranslateService, PermissionValidatorService, ApiResourceService, CookieService, USER_PERMISSIONS, COMPANY_PERMISSIONS, BRANCH_PERMISSIONS, resolveTranslationModule, SHARED_MESSAGES, permissionGuard, USER_PROVIDER, COMPANY_API_PROVIDER, USER_PERMISSION_PROVIDER, AUTH_STATE_PROVIDER, RouterTabsComponent, TranslatePipe, AngularModule, HasPermissionDirective, BaseFormComponent, BaseListComponent, BaseListTemplateDirective, FileUrlService, FILE_PROVIDER, PROFILE_PERMISSION_PROVIDER, FileUploaderComponent } from '@flusys/ng-shared';
|
|
9
9
|
import { map as map$1, catchError as catchError$1, tap as tap$1 } from 'rxjs/operators';
|
|
10
10
|
import * as i2$1 from '@angular/common';
|
|
11
11
|
import { isPlatformBrowser } from '@angular/common';
|
|
@@ -94,6 +94,7 @@ const STORAGE = {
|
|
|
94
94
|
COMPANY_ID: 'selectedCompanyId',
|
|
95
95
|
BRANCH_ID: 'selectedBranchId',
|
|
96
96
|
};
|
|
97
|
+
const SAVED_USER_NAME_KEY = 'savedUserName';
|
|
97
98
|
/**
|
|
98
99
|
* Auth State Service
|
|
99
100
|
* Minimal signal-based state management for authentication
|
|
@@ -106,6 +107,7 @@ class AuthStateService {
|
|
|
106
107
|
translateAdapter = inject(TranslateService, {
|
|
107
108
|
optional: true,
|
|
108
109
|
});
|
|
110
|
+
permissionValidator = inject(PermissionValidatorService);
|
|
109
111
|
// Core State (private writable, public readonly)
|
|
110
112
|
_user = signal(null, /* @ts-ignore */
|
|
111
113
|
...(ngDevMode ? [{ debugName: "_user" }] : /* istanbul ignore next */ []));
|
|
@@ -174,6 +176,13 @@ class AuthStateService {
|
|
|
174
176
|
? this.store(STORAGE.BRANCH_ID, branchId)
|
|
175
177
|
: this.remove(STORAGE.BRANCH_ID);
|
|
176
178
|
});
|
|
179
|
+
// Persist display name for the login page's "welcome back" greeting
|
|
180
|
+
effect(() => {
|
|
181
|
+
const user = this._user();
|
|
182
|
+
const name = user?.name?.trim() || user?.email;
|
|
183
|
+
if (name)
|
|
184
|
+
this.store(SAVED_USER_NAME_KEY, name);
|
|
185
|
+
});
|
|
177
186
|
// Load initial state from storage (expiry only, not token)
|
|
178
187
|
this.loadFromStorage();
|
|
179
188
|
}
|
|
@@ -206,6 +215,7 @@ class AuthStateService {
|
|
|
206
215
|
this._branch.set(null);
|
|
207
216
|
this.clearSelectionState();
|
|
208
217
|
Object.values(STORAGE).forEach((key) => this.remove(key));
|
|
218
|
+
this.permissionValidator.clearPermissions();
|
|
209
219
|
}
|
|
210
220
|
// ==========================================================================
|
|
211
221
|
// Individual Setters (for external use where needed)
|
|
@@ -250,6 +260,9 @@ class AuthStateService {
|
|
|
250
260
|
getStoredBranchId() {
|
|
251
261
|
return this.get(STORAGE.BRANCH_ID);
|
|
252
262
|
}
|
|
263
|
+
getSavedUserName() {
|
|
264
|
+
return this.get(SAVED_USER_NAME_KEY);
|
|
265
|
+
}
|
|
253
266
|
// Storage helpers
|
|
254
267
|
loadFromStorage() {
|
|
255
268
|
if (this.platform.isServer)
|
|
@@ -447,6 +460,10 @@ class UserApiService extends ApiResourceService {
|
|
|
447
460
|
updateProfile(data) {
|
|
448
461
|
return this.http.post(`${this.baseUrl}/profile`, data);
|
|
449
462
|
}
|
|
463
|
+
lookup(filter, search = '') {
|
|
464
|
+
const params = search ? { q: search } : undefined;
|
|
465
|
+
return this.http.post(`${this.baseUrl}/lookup`, filter, params ? { params } : undefined);
|
|
466
|
+
}
|
|
450
467
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: UserApiService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
451
468
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: UserApiService, providedIn: 'root' });
|
|
452
469
|
}
|
|
@@ -766,6 +783,7 @@ const AUTH_MESSAGES = {
|
|
|
766
783
|
'user.email.verify.success': 'Email verified successfully',
|
|
767
784
|
'user.phone.verify.success': 'Phone verified successfully',
|
|
768
785
|
'user.status.update.success': 'User status updated successfully',
|
|
786
|
+
'user.lookup.success': 'Users retrieved successfully',
|
|
769
787
|
// Company CRUD messages (API keys)
|
|
770
788
|
'company.create.success': 'Company created successfully',
|
|
771
789
|
'company.create.many.success': '{{count}} companies created successfully',
|
|
@@ -796,7 +814,8 @@ const AUTH_MESSAGES = {
|
|
|
796
814
|
'user.permission.not.found': '{{type}} permission not found',
|
|
797
815
|
// === UI KEYS — AUTH DOMAIN (AUTH_ROUTES: login, register, forgot-password, reset-password, verify-email) ===
|
|
798
816
|
// pages/login/login-page.component.ts
|
|
799
|
-
'auth.login.welcome': 'Welcome
|
|
817
|
+
'auth.login.welcome': 'Welcome!',
|
|
818
|
+
'auth.login.welcome.back': 'Welcome back, {{name}}!',
|
|
800
819
|
'auth.login.sign.in.to.continue': 'Sign in to continue to your account',
|
|
801
820
|
'auth.email.label': 'Email Address',
|
|
802
821
|
'auth.email.placeholder': 'Enter email address',
|
|
@@ -1330,7 +1349,7 @@ class AuthUserProviderAdapter {
|
|
|
1330
1349
|
},
|
|
1331
1350
|
sort: { name: 'ASC' },
|
|
1332
1351
|
};
|
|
1333
|
-
return
|
|
1352
|
+
return this.userApi.lookup(apiFilter, search ?? '').pipe(map((response) => ({
|
|
1334
1353
|
success: response.success,
|
|
1335
1354
|
message: response.message,
|
|
1336
1355
|
messageKey: response.messageKey,
|
|
@@ -3012,6 +3031,8 @@ class LoginPageComponent {
|
|
|
3012
3031
|
...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
|
|
3013
3032
|
unverifiedEmail = signal('', /* @ts-ignore */
|
|
3014
3033
|
...(ngDevMode ? [{ debugName: "unverifiedEmail" }] : /* istanbul ignore next */ []));
|
|
3034
|
+
savedUserName = signal(this.authState.getSavedUserName(), /* @ts-ignore */
|
|
3035
|
+
...(ngDevMode ? [{ debugName: "savedUserName" }] : /* istanbul ignore next */ []));
|
|
3015
3036
|
loginFormModel = signal({
|
|
3016
3037
|
email: '',
|
|
3017
3038
|
password: '',
|
|
@@ -3363,7 +3384,14 @@ class LoginPageComponent {
|
|
|
3363
3384
|
@if (currentStep() === 'credentials') {
|
|
3364
3385
|
<div class="text-center mb-8">
|
|
3365
3386
|
<div class="text-3xl font-medium mb-4 text-color">
|
|
3366
|
-
|
|
3387
|
+
@if (savedUserName()) {
|
|
3388
|
+
{{
|
|
3389
|
+
'auth.login.welcome.back'
|
|
3390
|
+
| translate: { name: savedUserName()! }
|
|
3391
|
+
}}
|
|
3392
|
+
} @else {
|
|
3393
|
+
{{ 'auth.login.welcome' | translate }}
|
|
3394
|
+
}
|
|
3367
3395
|
</div>
|
|
3368
3396
|
<span class="text-muted-color font-medium">{{
|
|
3369
3397
|
'auth.login.sign.in.to.continue' | translate
|
|
@@ -3635,7 +3663,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
3635
3663
|
@if (currentStep() === 'credentials') {
|
|
3636
3664
|
<div class="text-center mb-8">
|
|
3637
3665
|
<div class="text-3xl font-medium mb-4 text-color">
|
|
3638
|
-
|
|
3666
|
+
@if (savedUserName()) {
|
|
3667
|
+
{{
|
|
3668
|
+
'auth.login.welcome.back'
|
|
3669
|
+
| translate: { name: savedUserName()! }
|
|
3670
|
+
}}
|
|
3671
|
+
} @else {
|
|
3672
|
+
{{ 'auth.login.welcome' | translate }}
|
|
3673
|
+
}
|
|
3639
3674
|
</div>
|
|
3640
3675
|
<span class="text-muted-color font-medium">{{
|
|
3641
3676
|
'auth.login.sign.in.to.continue' | translate
|