Clinton
Posts: 0
Joined: Thu Oct 18, 2012 11:03 am

Authinticating user (REST) in login screen before navigating to next screen

Ok, So I have a login page which ha both a username and a password field. I am using the Prase REST service and I am logging in through. What would be the easiest way to check that the user logged in?

Here is my idea (but maybe you know of a better way):
I see that one of the responses from the service is "username" so I could probably get this and the in a custom JS I could check if (username == usernametxtinput.val). Firstly I'm not sure how to access the response variables fro the custom JS. Secondly I'm also not sure how to navigate to a page with JS.

Your help would be much appreciated

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Authinticating user (REST) in login screen before navigating to next screen

I think Parse returns a session id when the user logs in. You could save the id in local storage and then check it before navigating to the next page.

Clinton
Posts: 0
Joined: Thu Oct 18, 2012 11:03 am

Authinticating user (REST) in login screen before navigating to next screen

Yes, it is possible to get a session ID, so that would work to.

How would I reference a local storage variable in my javascript?

Clinton
Posts: 0
Joined: Thu Oct 18, 2012 11:03 am

Authinticating user (REST) in login screen before navigating to next screen

Great! Thank you.

Got it working with this in the end:

precode
var username = Tiggr('txtUsername').val();
var usernameSer = localStorage.getItem('myusername');

if (username == usernameSer) {
Tiggr.navigateTo('homeScreen');
}
/code/pre

Return to “Issues”