From 7fa0ee6a764ba197597782c703cf952c855704f8 Mon Sep 17 00:00:00 2001 From: Mazdak Gibran <141390141+mazdakgibran@users.noreply.github.com> Date: Tue, 23 Dec 2025 10:19:27 +0500 Subject: [PATCH] Change Password Screen view for first time login Show different change password screen view for first time login --- src/app/services/auth.service.ts | 1 + .../side-nav/side-nav.component.html | 2 +- .../components/side-nav/side-nav.component.ts | 10 ++- .../change-password.component.html | 78 +++++++++++++++++-- .../change-password.component.ts | 30 +++++-- src/assets/css/app.min.css | 1 + src/styles.scss | 3 + 7 files changed, 112 insertions(+), 13 deletions(-) diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index dd9e64f..6074aea 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -39,6 +39,7 @@ export class AuthService { localStorage.setItem('userId', res.user.userId); localStorage.setItem('token', res.token); this.firstLogin = response.requiresPasswordChange; + this.storageService.setItem('firstLogin', this.firstLogin ? 'true' : 'false'); return res; } diff --git a/src/app/shared/components/side-nav/side-nav.component.html b/src/app/shared/components/side-nav/side-nav.component.html index 7b3aa26..a4d7e2b 100644 --- a/src/app/shared/components/side-nav/side-nav.component.html +++ b/src/app/shared/components/side-nav/side-nav.component.html @@ -30,7 +30,7 @@
  • - + {{ 'changePassword' | translate }}
  • diff --git a/src/app/shared/components/side-nav/side-nav.component.ts b/src/app/shared/components/side-nav/side-nav.component.ts index 11aa213..eaa0d29 100644 --- a/src/app/shared/components/side-nav/side-nav.component.ts +++ b/src/app/shared/components/side-nav/side-nav.component.ts @@ -5,6 +5,7 @@ import { StorageService } from '../../services/storage.service'; import { isPlatformBrowser } from '@angular/common'; import { TranslateModule } from '@ngx-translate/core'; import { RouterModule } from '@angular/router'; +import { Router } from '@angular/router'; @Component({ selector: 'app-side-nav', @@ -22,7 +23,8 @@ export class SideNavComponent { constructor( private sidebarService: SidebarService, @Inject(PLATFORM_ID) private platformId: Object, - private storageService: StorageService + private storageService: StorageService, + private router: Router ) { // this.credentialService.getPermission().forEach((permission: any) => { // this.permissions[permission.name] = permission.checked; @@ -98,4 +100,10 @@ export class SideNavComponent { this.storageService.setItem('currentSubModule', lastRoutePart); } } + + navigateToChangePassword() { + this.router.navigate(['/home/changePassword'], { + state: { fromMenu: true } + }); +} } diff --git a/src/app/user-management/change-password/change-password.component.html b/src/app/user-management/change-password/change-password.component.html index e576a59..32f643f 100644 --- a/src/app/user-management/change-password/change-password.component.html +++ b/src/app/user-management/change-password/change-password.component.html @@ -1,17 +1,81 @@ +
    -
    -
    - \ No newline at end of file +
    diff --git a/src/app/user-management/change-password/change-password.component.ts b/src/app/user-management/change-password/change-password.component.ts index 212caa1..c0a1770 100644 --- a/src/app/user-management/change-password/change-password.component.ts +++ b/src/app/user-management/change-password/change-password.component.ts @@ -1,17 +1,27 @@ import { CommonModule } from '@angular/common'; import { Component, ViewChild } from '@angular/core'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'; import { TranslateModule } from '@ngx-translate/core'; import { PasswordHideShowComponent } from '../../shared/components/password-hide-show/password-hide-show.component'; - +import { StorageService } from '../../shared/services/storage.service'; +import { Router } from '@angular/router'; @Component({ selector: 'app-change-password', - imports: [TranslateModule, FormsModule, ReactiveFormsModule, CommonModule, PasswordHideShowComponent], + imports: [TranslateModule, FormsModule, ReactiveFormsModule, CommonModule, PasswordHideShowComponent,], templateUrl: './change-password.component.html', styleUrl: './change-password.component.scss' }) -export class ChangePasswordComponent { + +export class ChangePasswordComponent{ + isFirstLogin = false; + loginForm!: FormGroup; + currentLanguage = new FormControl(); + httpService: any; + constructor(private storageService: StorageService, private router: Router){} +onLangChange() { +throw new Error('Method not implemented.'); +} passwordType: string = 'password'; passwordType1: string = 'password'; passwordType2: string = 'password'; @@ -20,7 +30,6 @@ passwordType2: string = 'password'; @ViewChild('psh1') passwordHideShow1 ?: PasswordHideShowComponent; @ViewChild('psh2') passwordHideShow2 ?: PasswordHideShowComponent; - togglePasswordType() { this.passwordType = this.passwordHideShow?.showPassword ? 'password' : 'text'; } @@ -31,4 +40,15 @@ passwordType2: string = 'password'; this.passwordType2 = this.passwordHideShow2?.showPassword ? 'password' : 'text'; } + ngOnInit(): void { + const fromMenu = history.state?.['fromMenu']; + if(fromMenu){ + this.isFirstLogin = false; + }else{ + const firstLoginFlag = this.storageService.getItem('firstLogin'); + this.isFirstLogin = firstLoginFlag === 'true'; + } + } + + } diff --git a/src/assets/css/app.min.css b/src/assets/css/app.min.css index 84db9b4..2b886a0 100644 --- a/src/assets/css/app.min.css +++ b/src/assets/css/app.min.css @@ -4757,6 +4757,7 @@ button.btn.btn-primary{ position: absolute; width: 100%; height: 100%; + left: 0; } .card-header { diff --git a/src/styles.scss b/src/styles.scss index 7c3cb16..b902077 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -155,4 +155,7 @@ ng-select.form-select-sm { .password-eye * { font-size: 18px; } +.card-header{ + border: none !important; + }