Add hook to every page

#1

Hi Everybody!

I am building an ionic app, and I have a concern regarding the proper function of it.

My app has a login feature, and I need to get an authentication token from a server in order to make the subsequent calls to it.

For this purpose, I’d like to ensure that I have this authentication token in everyone of my pages, so that if I check on the dashboard page the authentication token and it doesn’t exists, I’ll redirect the user to the login page.

Is there any way to create a hook in some kind of “global” page, or in the class where my pages are inheriting it’s class? I know I could use the ionic lifecycle and hook there my login verification, but if I do it this way, I’d have to check on every one of my new pages, and I will be not following the DRY principle. I’d rather like to put a method on the app.component.ts file, and hook the method on that file. Is it possible?

Best,