1- import { Component , OnInit } from '@angular/core' ;
1+ import { Component , OnInit , ChangeDetectorRef , AfterViewInit } from '@angular/core' ;
22import { FormControl , FormGroup , Validators } from '@angular/forms' ;
33import { Router } from '@angular/router' ;
44import { User } from '../../shared/user' ;
@@ -16,7 +16,7 @@ import { Title } from '@angular/platform-browser';
1616 templateUrl : './userlogin.component.html' ,
1717 styleUrls : [ './userlogin.component.scss' ]
1818} )
19- export class UserloginComponent extends BaseComponent implements OnInit {
19+ export class UserloginComponent extends BaseComponent implements OnInit , AfterViewInit {
2020
2121 myForm : FormGroup ;
2222 errorMessage = false ;
@@ -30,7 +30,8 @@ export class UserloginComponent extends BaseComponent implements OnInit {
3030 private authService : AuthService ,
3131 private router : Router ,
3232 private user : UserService ,
33- private ts : Title
33+ private ts : Title ,
34+ private cdr : ChangeDetectorRef
3435 ) {
3536 super ( ts ) ;
3637 this . pageName = 'Solicitation Review Tool' ;
@@ -43,6 +44,26 @@ export class UserloginComponent extends BaseComponent implements OnInit {
4344 email : new FormControl ( '' , [ Validators . required ] ) ,
4445 password : new FormControl ( '' , [ Validators . required ] )
4546 } ) ;
47+
48+ // Force change detection cycle
49+ setTimeout ( ( ) => {
50+ this . cdr . detectChanges ( ) ;
51+ } , 0 ) ;
52+ }
53+
54+ ngAfterViewInit ( ) {
55+ // Check if we got here from a session timeout (token missing but other session data exists)
56+ const hasToken = localStorage . getItem ( 'token' ) ;
57+ const hasUserInfo = localStorage . getItem ( 'email' ) || localStorage . getItem ( 'id' ) ;
58+
59+ if ( ! hasToken && hasUserInfo ) {
60+ // Likely a timeout situation, clear remaining data
61+ localStorage . clear ( ) ;
62+
63+ // Force rendering
64+ this . cdr . detectChanges ( ) ;
65+
66+ }
4667 }
4768
4869 onSubmit ( ) {
0 commit comments