Kameron Berget
Posts: 0
Joined: Tue Apr 23, 2013 5:24 pm

User Login and Session Token

Can you give me some information on how the user login process works? I want to create a mechanism or JS function that can validate that a user is logged on. Right now my login_service is returning the session token to a localStorage variable. On page load I can check that variable (!mySessionToken) then {} but how can I validate is that session token is valid? Does it expire? I want users to be logged in as many of the things they do revolve around their users account. I don't want them to have to relogin repeatedly but want to have a way to validate the person is an active logged in user.

For example, if a user logs into my app and it is successful, it will bring them to the homeScreen. If it fails it will give them an error message. if they are inactive in the app for xDays when they open the app again how can I validate that they are a true user and their token is active?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

User Login and Session Token

Hi Kameron,

We do not have special API for check if user is logged in. But you can check session token validation by creating request to database. Call Rest Service to get user list. If session token is invalid then Rest Service will be finished with error.

Kameron Berget
Posts: 0
Joined: Tue Apr 23, 2013 5:24 pm

User Login and Session Token

Do I do this on behalf of the user during page load?

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

User Login and Session Token

Sure. You can do it any where in the app, on any event.

Kameron Berget
Posts: 0
Joined: Tue Apr 23, 2013 5:24 pm

User Login and Session Token

How do I submit a service request and include the session token?

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

User Login and Session Token

It's included as a header, similar to database id.

Kameron Berget
Posts: 0
Joined: Tue Apr 23, 2013 5:24 pm

User Login and Session Token

I am confused. I know how to invoke the list service but how can I ensure that the user will be reprompted for login when their token expires? is this automatic. Is there is easy way to protect each screen to only allow registered users to see it? My thought was that on screen load I could create a JS function that would verify that the session token was valid and if not redirect them to the login page.

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

User Login and Session Token

It's not automatic..it's something you need to implement.

Kameron Berget
Posts: 0
Joined: Tue Apr 23, 2013 5:24 pm

User Login and Session Token

Is there any way from my 'load' event to perform a check to see if the user has logged in? For instance. if upon successful login I set a local varialbel of loggedInUser to 'username' can I then check to ensure that value is not empty? Does the local variable get cleared at anytime? Does that experience differ for web app vs native apps?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

User Login and Session Token

Hi Kameron,

localStorage is not cleaned after you close site or quit the app. This is a permanent data storage. If you save sessionToken in any localStorage variable, then the variable will still keep its value when site/app opening.

Return to “Issues”