change password for first login fixed

change password for first login fixed
mazdak/UX-1572
Mazdak Gibran 2 days ago
parent bc18bcf946
commit 2b98437f15

@ -30,7 +30,7 @@
</a> </a>
</li> </li>
<li> <li>
<a routerLink="/home/changePassword" routerLinkActive="mm-active" style="cursor: pointer"> <a routerLink="/home/changePassword" routerLinkActive="mm-active" (click)="navigateToChangePassword()" style="cursor: pointer">
<span> {{ 'changePassword' | translate }}</span> <span> {{ 'changePassword' | translate }}</span>
</a> </a>
</li> </li>

@ -40,6 +40,12 @@ export class SideNavComponent {
this.sidebarService.currentSubModule = this.storageService.getItem('currentSubModule') ?? 'dashboard'; this.sidebarService.currentSubModule = this.storageService.getItem('currentSubModule') ?? 'dashboard';
this.closeSidebarMenu(); this.closeSidebarMenu();
} }
navigateToChangePassword() {
this.router.navigate(['/home/changePassword'], {
state: { fromMenu: true }
});
}
closeSidebarMenu(): void { closeSidebarMenu(): void {
if (isPlatformBrowser(this.platformId)) { if (isPlatformBrowser(this.platformId)) {
const subMenus = document.querySelectorAll('#sidebar-menu .sub-menu'); const subMenus = document.querySelectorAll('#sidebar-menu .sub-menu');

@ -41,18 +41,30 @@ passwordType2: string = 'password';
} }
ngOnInit(): void { ngOnInit(): void {
// Call the method to check if first-time login
this.checkIfFirstTimeChangePasswordOrNot(); this.checkIfFirstTimeChangePasswordOrNot();
} }
checkIfFirstTimeChangePasswordOrNot() { checkIfFirstTimeChangePasswordOrNot() {
let currentUser: any = JSON.parse(this.storageService.getItem('user')!) const fromMenu = history.state?.['fromMenu'];
if(currentUser.user.isFirstLogin){
if (fromMenu) {
this.isFirstLogin = false;
} else {
try {
const currentUser: any = JSON.parse(this.storageService.getItem('user') || '{}');
// Check if user exists and has isFirstLogin flag
if (currentUser?.user?.isFirstLogin) {
this.isFirstLogin = true; this.isFirstLogin = true;
} else {
this.isFirstLogin = false;
} }
else{ } catch (error) {
console.error('Error parsing user data:', error);
this.isFirstLogin = false; this.isFirstLogin = false;
} }
} }
}
} }

Loading…
Cancel
Save