Page 1 of 1

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

Posted: Thu Oct 18, 2012 3:40 pm
by Clinton

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


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

Posted: Thu Oct 18, 2012 4:26 pm
by maxkatz

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.


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

Posted: Thu Oct 18, 2012 4:30 pm
by Clinton

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?


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

Posted: Thu Oct 18, 2012 4:33 pm
by maxkatz

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

Posted: Thu Oct 18, 2012 5:38 pm
by Clinton

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