rajanmr
Posts: 0
Joined: Tue Apr 28, 2015 1:28 pm

How to keep users logged in, until they logout.

I have shared the app with the support, here are the details you asked for

1)app name : test3
2)credentials : Please register a new acc, so that you can know the problem
3) Detailed steps to reproduce the issue
Just register a new account, and then request the first service inside, then close the app and re-open the app, it will ask for login again

Thanks

rajanmr
Posts: 0
Joined: Tue Apr 28, 2015 1:28 pm

How to keep users logged in, until they logout.

Hi Stepanov!

Can you please confirm, that you have got access to the app?

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

How to keep users logged in, until they logout.

Hi Rajan -

Yes, we have access to your app. We need some time to test it on a device.

rajanmr
Posts: 0
Joined: Tue Apr 28, 2015 1:28 pm

How to keep users logged in, until they logout.

ok thanks, will await your reply.

rajanmr
Posts: 0
Joined: Tue Apr 28, 2015 1:28 pm

How to keep users logged in, until they logout.

Hi!

i am still waiting for your reply.

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

How to keep users logged in, until they logout.

Sorry for delay. Working on it.
We'll reply as soon as have news.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How to keep users logged in, until they logout.

Hi rajanmr,

The problem you have is not in login. After app restarts - it will load start screen. Your start screen is login thus you have this form.

Your local storage variable stored after restart the app and you need to check it and pass login page(navigate to needed page).

Regards.

rajanmr
Posts: 0
Joined: Tue Apr 28, 2015 1:28 pm

How to keep users logged in, until they logout.

Thanks Yuri!

Can you throw some light into how and what to check with the local storage variable. Should i have a blank page as start screen and check whether sessionid is available in local storage? Please clarify what to check.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How to keep users logged in, until they logout.

Ramanmr,

Yes here is a solution to check if session token stored, verify this token and then make logic what to open.

  1. At first add to your app "getUser"(call it the same) service.
    Solution how to do will be posted below.

  2. Create new page and call it "verifyUser". You can populate this page with content you need to show/or not show about current process.

  3. Make this page as start page of your app.

  4. Add to this page on "Data" tab "getUser" service datasource and call it "getUserDatasource".
    Details: http://prntscr.com/778aa7/direct

  5. Open "Before send" mapping for "getUserDatasource". And link from storage(where you store your sessionToken) to "X-Appery-Sessoin-token" request parameter. And inside "userId" request parameter put "111".
    Details: http://prntscr.com/778bwz/direct

  6. Add "Complete" event handler with action "Run javascript". And use following JS code for this handler:
    Details: http://prntscr.com/778e1h/direct

    precode

    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("test");
    }
    else{
    //Navigate to login page if session token is NOT correct.
    Apperyio.navigateTo("login");
    };

    /code/pre

    Note: you need to change "test" and "login" page with your destination pages.

  7. Invoke this service datasource on the "page show event handler.
    Details: http://prntscr.com/778eah/direct

    That's all.

    Regards.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How to keep users logged in, until they logout.

And here is a solution about how to add "getUser" service in your app:

  1. Create REST service and call it "getUser".
    Details: http://prntscr.com/5vurg1/direct

  2. On "Settings tab" use following settings:
    Details: http://prntscr.com/5vusim/direct

    URL: "https://api.appery.io/rest/1/db/users..."
    Method: "GET"
    Response Data Type: "JSON"
    Settings: your DB settings service.

  3. Request tab(headers):
    Details: http://prntscr.com/5vutfn/direct

    Add following parameters:
    "X-Appery-Database-Id" = "{database_id}"
    "X-Appery-Session-Token" = ""

  4. Request tab(queryString):
    Details: http://prntscr.com/5vut9y/direct

    Add following parameters:
    "userId" = ""

  5. In "response" tab you need to set your user details parameters. Like on the screen shots: http://prntscr.com/5vutoh/direct

    Regards.

Return to “Issues”