Handling @ng-idle globally for all pages


#1

Hello, please i am pretty new in this, i know its a silly question to ask, but pardon me.
i have a block of code which i got from (https://hackedbychinese.github.io/ng2-idle/) on how to implement a timeout on idle session, but please from the code it was just implemented on a page, but in my case i have over 10 pages in my ionic 2 project apart from the Login page, do i need to put this code in every page (which i think is cumbersome) or is there any way to make it global? so that if i am to change the idle time , it affects all


#2

That README looks like it uses the app component, which should be “global” for all intents and purposes.


#3

thank you for your reply, but if its global, it the affects the login page, because if also the login page is not active it will also perform the same action, which is not right, or from your experience what do you advice, what i am trying to achieve is if the user is inactive for a certain amount of time (which i will define) it logs the user out


#4

Here is how I handle user authentication. If you choose to adopt this strategy, your idle handler can simply call authNotifier.next(false) to log the user out, and the app will automatically move to the login page.