Jon Haider
Posts: 0
Joined: Thu Oct 16, 2014 2:53 pm

I am using Auth0 for sign ups, and storing sign ups and log ins in the Users Database. How do I keep a user signed in?

Hey Avery,

It sounds like what you need to do from a logical standpoint is keep the splash screen displayed upon device ready (which you can research how to do by editing the xml or plist file - I can't remember which one), and upon "deviceReady" have a way to determine if the device is owned by someone who has previously signed in. Maybe save their sessionToken or username/password to Local Storage Variables, and validate the info in this LSV with your database, if the info is validated, navigate them to the "next page" and THEN hide the splash screen.

If the information cannot be validated, then you should take them to the signup/login page.

(As a side now, why don't you have a login page as default, and have a button for signing up, which will then display the signup form, using show() and hide()? But that's not relevant for this issue).

I hope this helps.

A.W.H.
Posts: 0
Joined: Sat Jun 20, 2015 7:02 am

I am using Auth0 for sign ups, and storing sign ups and log ins in the Users Database. How do I keep a user signed in?

What would be the javascript for testing if the user's sessionToken is valid?

Currently, I have the following:

var responseText = jqXHR.responseText;
var responseObject = JSON.parse(responseText);
var isSessionCorrect = false;
if(responseObject.code == "DBUG210")
isSessionCorrect = true;
console.log("isSessionCorrect = " + isSessionCorrect);
if(isSessionCorrect){
//Navigate to page you need if session token is correct.
Apperyio.navigateTo("Inbox_Page");
}
else{
//Navigate to login page if session token is NOT correct.
Apperyio.navigateTo("Auth0_Home");
};

Jon Haider
Posts: 0
Joined: Thu Oct 16, 2014 2:53 pm

I am using Auth0 for sign ups, and storing sign ups and log ins in the Users Database. How do I keep a user signed in?

https://c.getsatisfaction.com/apperyi...

You're better off saving and validating the username and password anyways since the sessionToken is only valid for a couple hours...

A.W.H.
Posts: 0
Joined: Sat Jun 20, 2015 7:02 am

I am using Auth0 for sign ups, and storing sign ups and log ins in the Users Database. How do I keep a user signed in?

I tried implementing that code and couldn't get it working. In fact, I can't even console.log the localStorage userSessionToken variable. It shows up as undefined.

A.W.H.
Posts: 0
Joined: Sat Jun 20, 2015 7:02 am

I am using Auth0 for sign ups, and storing sign ups and log ins in the Users Database. How do I keep a user signed in?

Can you type up the code to verify a user's locally stored sessionToken to verify that they're able to log in?

Also, I log in through Auth0, so I'm not sure how to get the user's username and password.

A.W.H.
Posts: 0
Joined: Sat Jun 20, 2015 7:02 am

I am using Auth0 for sign ups, and storing sign ups and log ins in the Users Database. How do I keep a user signed in?

Now, I store my userSessionToken in local storage (after a user signs in). When I close and re-open the app, I can't validate the sessionToken. I can print it, on the next page, after signing in and it's correct. If I print it on the splash page, it appears in the console debugger as the same string as the DB Master-Key.

A.W.H.
Posts: 0
Joined: Sat Jun 20, 2015 7:02 am

I am using Auth0 for sign ups, and storing sign ups and log ins in the Users Database. How do I keep a user signed in?

Hi, I've seemed to have figured some of this out.

The part I'm having a problem with is getting the correct sessionToken to go through and let me skip the login when I open up the app.

When I log in and print the sessionToken, it works.

When I open the app and automatically check the sessionToken to get the user's profile and see if it retrieves it properly from the database, it fails, and uses the wrong sessionToken. Don't know why.

See the bottom 2 lines

Image

Return to “Issues”