@flusys/ng-auth 6.2.1 → 6.2.2
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)
|
|
@@ -796,7 +809,8 @@ const AUTH_MESSAGES = {
|
|
|
796
809
|
'user.permission.not.found': '{{type}} permission not found',
|
|
797
810
|
// === UI KEYS — AUTH DOMAIN (AUTH_ROUTES: login, register, forgot-password, reset-password, verify-email) ===
|
|
798
811
|
// pages/login/login-page.component.ts
|
|
799
|
-
'auth.login.welcome': 'Welcome
|
|
812
|
+
'auth.login.welcome': 'Welcome!',
|
|
813
|
+
'auth.login.welcome.back': 'Welcome back, {{name}}!',
|
|
800
814
|
'auth.login.sign.in.to.continue': 'Sign in to continue to your account',
|
|
801
815
|
'auth.email.label': 'Email Address',
|
|
802
816
|
'auth.email.placeholder': 'Enter email address',
|
|
@@ -3012,6 +3026,8 @@ class LoginPageComponent {
|
|
|
3012
3026
|
...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
|
|
3013
3027
|
unverifiedEmail = signal('', /* @ts-ignore */
|
|
3014
3028
|
...(ngDevMode ? [{ debugName: "unverifiedEmail" }] : /* istanbul ignore next */ []));
|
|
3029
|
+
savedUserName = signal(this.authState.getSavedUserName(), /* @ts-ignore */
|
|
3030
|
+
...(ngDevMode ? [{ debugName: "savedUserName" }] : /* istanbul ignore next */ []));
|
|
3015
3031
|
loginFormModel = signal({
|
|
3016
3032
|
email: '',
|
|
3017
3033
|
password: '',
|
|
@@ -3363,7 +3379,14 @@ class LoginPageComponent {
|
|
|
3363
3379
|
@if (currentStep() === 'credentials') {
|
|
3364
3380
|
<div class="text-center mb-8">
|
|
3365
3381
|
<div class="text-3xl font-medium mb-4 text-color">
|
|
3366
|
-
|
|
3382
|
+
@if (savedUserName()) {
|
|
3383
|
+
{{
|
|
3384
|
+
'auth.login.welcome.back'
|
|
3385
|
+
| translate: { name: savedUserName()! }
|
|
3386
|
+
}}
|
|
3387
|
+
} @else {
|
|
3388
|
+
{{ 'auth.login.welcome' | translate }}
|
|
3389
|
+
}
|
|
3367
3390
|
</div>
|
|
3368
3391
|
<span class="text-muted-color font-medium">{{
|
|
3369
3392
|
'auth.login.sign.in.to.continue' | translate
|
|
@@ -3635,7 +3658,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
3635
3658
|
@if (currentStep() === 'credentials') {
|
|
3636
3659
|
<div class="text-center mb-8">
|
|
3637
3660
|
<div class="text-3xl font-medium mb-4 text-color">
|
|
3638
|
-
|
|
3661
|
+
@if (savedUserName()) {
|
|
3662
|
+
{{
|
|
3663
|
+
'auth.login.welcome.back'
|
|
3664
|
+
| translate: { name: savedUserName()! }
|
|
3665
|
+
}}
|
|
3666
|
+
} @else {
|
|
3667
|
+
{{ 'auth.login.welcome' | translate }}
|
|
3668
|
+
}
|
|
3639
3669
|
</div>
|
|
3640
3670
|
<span class="text-muted-color font-medium">{{
|
|
3641
3671
|
'auth.login.sign.in.to.continue' | translate
|