From 94c96287f358da2278513090b086d53ba190c885 Mon Sep 17 00:00:00 2001 From: sumeyye Date: Tue, 16 Jun 2026 16:40:16 +0300 Subject: [PATCH] update: some upgrade enhancements for the account --- .../change-password.component.html | 23 ++--- .../change-password.component.ts | 23 +++-- .../forgot-password.component.html | 14 +-- .../forgot-password.component.ts | 8 +- .../lib/components/login/login.component.ts | 3 +- .../manage-profile.component.html | 90 +++++++++++-------- .../manage-profile.component.ts | 21 +++-- .../personal-settings-half-row.component.ts | 3 +- .../personal-settings.component.ts | 12 ++- .../components/register/register.component.ts | 10 ++- .../reset-password.component.html | 83 +++++++++-------- .../reset-password.component.ts | 33 +++++-- 12 files changed, 193 insertions(+), 130 deletions(-) diff --git a/npm/ng-packs/packages/account/src/lib/components/change-password/change-password.component.html b/npm/ng-packs/packages/account/src/lib/components/change-password/change-password.component.html index d238955582..69608d6bad 100644 --- a/npm/ng-packs/packages/account/src/lib/components/change-password/change-password.component.html +++ b/npm/ng-packs/packages/account/src/lib/components/change-password/change-password.component.html @@ -5,13 +5,13 @@ [validateOnSubmit]="true" class="abp-md-form" > - @if (!hideCurrentPassword) { + @if (!hideCurrentPassword()) {
* + * + * + * + * + * + {{ 'AbpIdentity::Save' | abpLocalization }} + {{ 'AbpIdentity::Save' | abpLocalization }} + diff --git a/npm/ng-packs/packages/account/src/lib/components/change-password/change-password.component.ts b/npm/ng-packs/packages/account/src/lib/components/change-password/change-password.component.ts index 0dff0a60ab..1673601729 100644 --- a/npm/ng-packs/packages/account/src/lib/components/change-password/change-password.component.ts +++ b/npm/ng-packs/packages/account/src/lib/components/change-password/change-password.component.ts @@ -1,6 +1,13 @@ import { ProfileService } from '@abp/ng.account.core/proxy'; import { ButtonComponent, getPasswordValidators, ToasterService } from '@abp/ng.theme.shared'; -import { Component, Injector, OnInit, inject, signal } from '@angular/core'; +import { + Component, + Injector, + OnInit, + inject, + signal, + ChangeDetectionStrategy, +} from '@angular/core'; import { ReactiveFormsModule, UntypedFormBuilder, @@ -18,6 +25,7 @@ const { required } = Validators; const PASSWORD_FIELDS = ['newPassword', 'repeatNewPassword']; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, selector: 'abp-change-password-form', templateUrl: './change-password.component.html', exportAs: 'abpChangePasswordForm', @@ -41,8 +49,7 @@ export class ChangePasswordComponent form!: UntypedFormGroup; readonly inProgress = signal(false); - - hideCurrentPassword?: boolean; + readonly hideCurrentPassword = signal(false); mapErrorsFn: Validation.MapErrorsFn = (errors, groupErrors, control) => { if (PASSWORD_FIELDS.indexOf(String(control?.name)) < 0) return errors; @@ -51,7 +58,7 @@ export class ChangePasswordComponent }; ngOnInit(): void { - this.hideCurrentPassword = !this.manageProfileState.getProfile()?.hasPassword; + this.hideCurrentPassword.set(!this.manageProfileState.getProfile()?.hasPassword); const passwordValidations = getPasswordValidators(this.injector); @@ -76,7 +83,7 @@ export class ChangePasswordComponent }, ); - if (this.hideCurrentPassword) this.form.removeControl('password'); + if (this.hideCurrentPassword()) this.form.removeControl('password'); } onSubmit() { @@ -84,7 +91,7 @@ export class ChangePasswordComponent this.inProgress.set(true); this.profileService .changePassword({ - ...(!this.hideCurrentPassword && { currentPassword: this.form.get('password')?.value }), + ...(!this.hideCurrentPassword() && { currentPassword: this.form.get('password')?.value }), newPassword: this.form.get('newPassword')?.value, }) .pipe(finalize(() => this.inProgress.set(false))) @@ -95,8 +102,8 @@ export class ChangePasswordComponent life: 5000, }); - if (this.hideCurrentPassword) { - this.hideCurrentPassword = false; + if (this.hideCurrentPassword()) { + this.hideCurrentPassword.set(false); this.form.addControl('password', new UntypedFormControl('', [required])); } }, diff --git a/npm/ng-packs/packages/account/src/lib/components/forgot-password/forgot-password.component.html b/npm/ng-packs/packages/account/src/lib/components/forgot-password/forgot-password.component.html index e967d594cc..ba415340b2 100644 --- a/npm/ng-packs/packages/account/src/lib/components/forgot-password/forgot-password.component.html +++ b/npm/ng-packs/packages/account/src/lib/components/forgot-password/forgot-password.component.html @@ -1,13 +1,13 @@

{{ 'AbpAccount::ForgotPassword' | abpLocalization }}

-@if (!isEmailSent) { +@if (!isEmailSent()) {

{{ 'AbpAccount::SendPasswordResetLink_Information' | abpLocalization }}

* + }} + *
{{ 'AbpAccount::Submit' | abpLocalization }} - {{ 'AbpAccount::Login' | abpLocalization }} + + + {{ 'AbpAccount::Login' | abpLocalization }} +
} @else {

diff --git a/npm/ng-packs/packages/account/src/lib/components/forgot-password/forgot-password.component.ts b/npm/ng-packs/packages/account/src/lib/components/forgot-password/forgot-password.component.ts index 243cb62f77..d77ecc3b2b 100644 --- a/npm/ng-packs/packages/account/src/lib/components/forgot-password/forgot-password.component.ts +++ b/npm/ng-packs/packages/account/src/lib/components/forgot-password/forgot-password.component.ts @@ -1,5 +1,5 @@ import { AccountService } from '@abp/ng.account.core/proxy'; -import { Component, inject, signal } from '@angular/core'; +import { Component, inject, signal, ChangeDetectionStrategy } from '@angular/core'; import { ReactiveFormsModule, UntypedFormBuilder, @@ -13,6 +13,7 @@ import { RouterLink } from '@angular/router'; import { NgxValidateCoreModule } from '@ngx-validate/core'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, selector: 'abp-forgot-password', templateUrl: 'forgot-password.component.html', imports: [ @@ -30,8 +31,7 @@ export class ForgotPasswordComponent { form: UntypedFormGroup; readonly inProgress = signal(false); - - isEmailSent = false; + readonly isEmailSent = signal(false); constructor() { this.form = this.fb.group({ @@ -51,7 +51,7 @@ export class ForgotPasswordComponent { }) .pipe(finalize(() => this.inProgress.set(false))) .subscribe(() => { - this.isEmailSent = true; + this.isEmailSent.set(true); }); } } diff --git a/npm/ng-packs/packages/account/src/lib/components/login/login.component.ts b/npm/ng-packs/packages/account/src/lib/components/login/login.component.ts index 2fb90f55cd..c85d766367 100644 --- a/npm/ng-packs/packages/account/src/lib/components/login/login.component.ts +++ b/npm/ng-packs/packages/account/src/lib/components/login/login.component.ts @@ -1,4 +1,4 @@ -import { Component, Injector, OnInit, inject, signal } from '@angular/core'; +import { Component, Injector, OnInit, inject, signal, ChangeDetectionStrategy } from '@angular/core'; import { ReactiveFormsModule, UntypedFormBuilder, @@ -22,6 +22,7 @@ import { getRedirectUrl } from '../../utils'; const { maxLength, required } = Validators; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, selector: 'abp-login', templateUrl: './login.component.html', imports: [ diff --git a/npm/ng-packs/packages/account/src/lib/components/manage-profile/manage-profile.component.html b/npm/ng-packs/packages/account/src/lib/components/manage-profile/manage-profile.component.html index 91167b0ede..1ca3e1e457 100644 --- a/npm/ng-packs/packages/account/src/lib/components/manage-profile/manage-profile.component.html +++ b/npm/ng-packs/packages/account/src/lib/components/manage-profile/manage-profile.component.html @@ -1,51 +1,65 @@

-
+
- @if (profile$ | async) { -
- @if (selectedTab === 0) { -
-
-

- {{ 'AbpIdentity::ChangePassword' | abpLocalization }} -
-

- -
-
- } - @if (selectedTab === 1) { -
-
-

- {{ 'AbpIdentity::PersonalSettings' | abpLocalization }} -
-

- -
+ @if (profile()) { +
+ @if (selectedTab() === 0) { +
+
+

+ {{ 'AbpIdentity::ChangePassword' | abpLocalization }} +
+

+ +
+
+ } + @if (selectedTab() === 1) { +
+
+

+ {{ 'AbpIdentity::PersonalSettings' | abpLocalization }} +
+

+ +
+
+ }
- } -
}
-
\ No newline at end of file +
diff --git a/npm/ng-packs/packages/account/src/lib/components/manage-profile/manage-profile.component.ts b/npm/ng-packs/packages/account/src/lib/components/manage-profile/manage-profile.component.ts index 5be91d34f7..4ce1b0e228 100644 --- a/npm/ng-packs/packages/account/src/lib/components/manage-profile/manage-profile.component.ts +++ b/npm/ng-packs/packages/account/src/lib/components/manage-profile/manage-profile.component.ts @@ -1,15 +1,16 @@ import { ProfileService } from '@abp/ng.account.core/proxy'; import { LoadingDirective } from '@abp/ng.theme.shared'; -import { Component, inject, OnInit } from '@angular/core'; +import { Component, inject, OnInit, signal, ChangeDetectionStrategy } from '@angular/core'; +import { toSignal } from '@angular/core/rxjs-interop'; import { eAccountComponents } from '../../enums/components'; import { ManageProfileStateService } from '../../services/manage-profile.state.service'; -import { AsyncPipe } from '@angular/common'; import { ReactiveFormsModule } from '@angular/forms'; import { LocalizationPipe, ReplaceableTemplateDirective } from '@abp/ng.core'; import { PersonalSettingsComponent } from '../personal-settings/personal-settings.component'; import { ChangePasswordComponent } from '../change-password/change-password.component'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, selector: 'abp-manage-profile', templateUrl: './manage-profile.component.html', styles: [ @@ -33,35 +34,33 @@ import { ChangePasswordComponent } from '../change-password/change-password.comp `, ], imports: [ - AsyncPipe, ReactiveFormsModule, PersonalSettingsComponent, ChangePasswordComponent, LocalizationPipe, ReplaceableTemplateDirective, - LoadingDirective + LoadingDirective, ], }) export class ManageProfileComponent implements OnInit { protected profileService = inject(ProfileService); protected manageProfileState = inject(ManageProfileStateService); - selectedTab = 0; + readonly selectedTab = signal(0); + readonly hideChangePasswordTab = signal(false); + + readonly profile = toSignal(this.manageProfileState.getProfile$()); changePasswordKey = eAccountComponents.ChangePassword; personalSettingsKey = eAccountComponents.PersonalSettings; - profile$ = this.manageProfileState.getProfile$(); - - hideChangePasswordTab?: boolean; - ngOnInit() { this.profileService.get().subscribe(profile => { this.manageProfileState.setProfile(profile); if (profile.isExternal) { - this.hideChangePasswordTab = true; - this.selectedTab = 1; + this.hideChangePasswordTab.set(true); + this.selectedTab.set(1); } }); } diff --git a/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings-half-row.component.ts b/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings-half-row.component.ts index be6287e954..4e870b1820 100644 --- a/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings-half-row.component.ts +++ b/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings-half-row.component.ts @@ -1,4 +1,4 @@ -import { Component, inject } from '@angular/core'; +import { Component, inject, ChangeDetectionStrategy } from '@angular/core'; import { EXTENSIONS_FORM_PROP, FormProp, @@ -8,6 +8,7 @@ import { ReactiveFormsModule, UntypedFormGroup } from '@angular/forms'; import { LocalizationPipe } from '@abp/ng.core'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, selector: 'abp-personal-settings-half-row', template: `
diff --git a/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings.component.ts b/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings.component.ts index 81311f06f9..5019a6eab9 100644 --- a/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings.component.ts +++ b/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings.component.ts @@ -5,8 +5,16 @@ import { ConfirmationService, ToasterService, } from '@abp/ng.theme.shared'; -import { Component, inject, Injector, OnInit, signal } from '@angular/core'; +import { + Component, + inject, + Injector, + OnInit, + signal, + ChangeDetectionStrategy, +} from '@angular/core'; import { ReactiveFormsModule, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; +import { NgxValidateCoreModule } from '@ngx-validate/core'; import { finalize, filter } from 'rxjs/operators'; import { Account } from '../../models/account'; import { ManageProfileStateService } from '../../services/manage-profile.state.service'; @@ -19,9 +27,9 @@ import { generateFormFromProps, } from '@abp/ng.components/extensible'; import { eAccountComponents } from '../../enums'; -import { NgxValidateCoreModule } from '@ngx-validate/core'; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, selector: 'abp-personal-settings-form', templateUrl: './personal-settings.component.html', exportAs: 'abpPersonalSettingsForm', diff --git a/npm/ng-packs/packages/account/src/lib/components/register/register.component.ts b/npm/ng-packs/packages/account/src/lib/components/register/register.component.ts index 41b46621eb..20e8983021 100644 --- a/npm/ng-packs/packages/account/src/lib/components/register/register.component.ts +++ b/npm/ng-packs/packages/account/src/lib/components/register/register.component.ts @@ -6,7 +6,14 @@ import { LocalizationPipe, } from '@abp/ng.core'; import { ButtonComponent, getPasswordValidators, ToasterService } from '@abp/ng.theme.shared'; -import { Component, Injector, OnInit, inject, signal } from '@angular/core'; +import { + Component, + Injector, + OnInit, + inject, + signal, + ChangeDetectionStrategy, +} from '@angular/core'; import { ReactiveFormsModule, UntypedFormBuilder, @@ -23,6 +30,7 @@ import { RouterLink } from '@angular/router'; const { maxLength, required, email } = Validators; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, selector: 'abp-register', templateUrl: './register.component.html', imports: [ diff --git a/npm/ng-packs/packages/account/src/lib/components/reset-password/reset-password.component.html b/npm/ng-packs/packages/account/src/lib/components/reset-password/reset-password.component.html index 518eabdc05..847adb4262 100644 --- a/npm/ng-packs/packages/account/src/lib/components/reset-password/reset-password.component.html +++ b/npm/ng-packs/packages/account/src/lib/components/reset-password/reset-password.component.html @@ -1,44 +1,51 @@

{{ 'AbpAccount::ResetPassword' | abpLocalization }}

-@if (!isPasswordReset) { -
-

{{ 'AbpAccount::ResetPassword_Information' | abpLocalization }}

-
- * - -
-
- * - -
- - - {{ 'AbpAccount::Submit' | abpLocalization }} - -
+

{{ 'AbpAccount::ResetPassword_Information' | abpLocalization }}

+
+ + * + +
+
+ + * + +
+ + + {{ 'AbpAccount::Submit' | abpLocalization }} + + + } } @else {

{{ 'AbpAccount::YourPasswordIsSuccessfullyReset' | abpLocalization }} diff --git a/npm/ng-packs/packages/account/src/lib/components/reset-password/reset-password.component.ts b/npm/ng-packs/packages/account/src/lib/components/reset-password/reset-password.component.ts index 97d7776140..25879ac653 100644 --- a/npm/ng-packs/packages/account/src/lib/components/reset-password/reset-password.component.ts +++ b/npm/ng-packs/packages/account/src/lib/components/reset-password/reset-password.component.ts @@ -1,6 +1,14 @@ import { AccountService } from '@abp/ng.account.core/proxy'; import { ButtonComponent, getPasswordValidators } from '@abp/ng.theme.shared'; -import { Component, Injector, OnInit, inject, signal } from '@angular/core'; +import { + Component, + effect, + Injector, + inject, + signal, + ChangeDetectionStrategy, +} from '@angular/core'; +import { toSignal } from '@angular/core/rxjs-interop'; import { ReactiveFormsModule, UntypedFormBuilder, @@ -15,6 +23,7 @@ import { LocalizationPipe } from '@abp/ng.core'; const PASSWORD_FIELDS = ['password', 'confirmPassword']; @Component({ + changeDetection: ChangeDetectionStrategy.OnPush, selector: 'abp-reset-password', templateUrl: './reset-password.component.html', imports: [ @@ -25,18 +34,19 @@ const PASSWORD_FIELDS = ['password', 'confirmPassword']; ButtonComponent, ], }) -export class ResetPasswordComponent implements OnInit { +export class ResetPasswordComponent { private fb = inject(UntypedFormBuilder); private accountService = inject(AccountService); private route = inject(ActivatedRoute); private router = inject(Router); private injector = inject(Injector); + private readonly queryParams = toSignal(this.route.queryParams); + form!: UntypedFormGroup; readonly inProgress = signal(false); - - isPasswordReset = false; + readonly isPasswordReset = signal(false); mapErrorsFn: Validation.MapErrorsFn = (errors, groupErrors, control) => { if (PASSWORD_FIELDS.indexOf(String(control?.name)) < 0) return errors; @@ -44,9 +54,16 @@ export class ResetPasswordComponent implements OnInit { return errors.concat(groupErrors.filter(({ key }) => key === 'passwordMismatch')); }; - ngOnInit(): void { - this.route.queryParams.subscribe(({ userId, resetToken }) => { - if (!userId || !resetToken) this.router.navigateByUrl('/account/login'); + constructor() { + effect(() => { + const params = this.queryParams(); + if (!params) return; + + const { userId, resetToken } = params; + if (!userId || !resetToken) { + void this.router.navigateByUrl('/account/login'); + return; + } this.form = this.fb.group( { @@ -75,7 +92,7 @@ export class ResetPasswordComponent implements OnInit { }) .pipe(finalize(() => this.inProgress.set(false))) .subscribe(() => { - this.isPasswordReset = true; + this.isPasswordReset.set(true); }); } }