Mochoa
Mochoa

Reputation: 153

What is the best practice to manage sessions with Ionic 2

i have an app on ionic 2 and i dont know how to manage the user session, i wanna that the user inserts his credentials every time that launch the app

Upvotes: 1

Views: 1386

Answers (1)

Chris
Chris

Reputation: 4728

You should use Ionic Auth - https://ionic.io/docs/auth-connect

This page is pretty clear in explaining what you need to do. There are also several methods of authentication. You can use Ionic's backend services to handle this for you. Alternatively you can handle the authentication at your end and return a JWT. There are also many social logins available.

On your specific point about wanting users to log in each time they open the app. I'll draw your attention to the final section of the URL.

How can I require users to login every time the app is opened?

By default, we keep users logged in. If you only want them to be logged in for the duration of the app being opened, you need to set remember: false in your login options.

this.auth.login('basic', details, {'remember': false});

Upvotes: 1

Related Questions