Ionic user authentication


Am trying to add user authentication to my app. i have been able send information from the login form to the server but how do i restrict access to pages i don’t want users to have access to, unless they are logged in.
Am still very new to ionic so a comprehensive answer will be really appreciated.


There are endless ways this can be approached. It also depends on how your application is designed.

If your application starts with a login page, wait for the server response and only proceed to your main application page only if they input valid credentials.

If your application displays your main application page upon boot, you can keep track of their login status using a simple flag in your scope. Whenever the user wants to navigate, check this flag and if they are not logged in, do not let them proceed.


Hi Joonh127, my server expects NTLM authentication. When I make a request to the server in address bar of Chrome, it prompts for username/password…However, when I try to request using http.get of Angular2/Ionic-v2, I simply get 401 error. How can I make browser to prompt for username/password while using Angular2 ? (Using Angular1, I did not face this issue). Any pointers are highly appreciated. Thanks.


Sorry. I am unfamiliar with NTLM and Angular 2


thanks but how do i go about create this type of flow. can you help with an example.


Or do i use something like “state.go” to redirect to the requested page after login credentials as been confirmed from the server or what would you advise.


Yeah you can do that. On post and response success for login, you can $state.go to the main application state.