Hello Team, I could use some assistance regarding a validation issue.
I am looking for a solution to automatically close my web page if the user does not respond with either "yes" or "no" within 30 minutes.
constructor(private loginService:AuthenticationService,private router: Router) {
this.setTimeout();
this.userInactive.subscribe(()=> this.cancel());
}
setTimeout() {
this.userActivity = setTimeout(() => this.userInactive.next(undefined), 300000);
}
@HostListener('window:mousemove') refreshUserState() {
clearTimeout(this.userActivity);
this.setTimeout();
}
cancel() {
var cancel = confirm("We have detected inactivity. Would you like to continue?");
if (cancel) {
return true;
} else {
this.router.navigate(['/logout']);
return false;
}
}