How to Get the logged-In Username

Home Forums Convertigo developers Forums as moved to Stack Overflow. How to Get the logged-In Username

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #134305

    RItesh K
    Participant

    Hi All

    Currently i am using the example “Room Search” project for learning. There we have login form.
    I am able to replicate that with my learning project.

    I am building a page called “My Accounts”
    under this section i want to display the logged in user’s username.

    How can i retrieve the current session user’s username by using C80 API?

    Thanks

    #134313

    Gregory Vorbe
    Moderator

    Hello Ritesh,

    In the sampleMobileSearchRoom project we use the HTML5 localStorage object to locally store on device the username and password in clear text.
    You could use some jQuery in custom.js to set the user’s name when showing your “My Accounts” page:

    $("#userId").val(localStorage.getItem("userId"));

    Or, you could use the Set Autenticated user step in your login sequence and the Get Authenticated user in the beginning all of your other sequences.
    This way you could check that the user’s session is still alive in the server (default HTTP session timeout is 300s per project) and make an XML output of the user’s name to retrieve it with CTF in your html pages.

    Support&QA

    #137538

    Shweta
    Participant

    Hi ,

    Can you please give me some idea on Set Authenticated user and Get Authenticated user and how the data could be fetched from this step.

    Thanks

    #138298

    Gregory Vorbe
    Moderator

    Hello,

    I have made a very simple sample mobile project for you to see how to use the Set/GetAuthenticatedUser Step.
    There are four sequences: login, checkAuthenticatedUser, next and logout.

    _ Use ‘login’ with c8o/test credentials to save the user name in the user HTTP session.
    _ ‘next’ sequence first calls ‘checkAuthenticatedUser’ to check if user session is still alive. You can then take decision according to the response.
    _ You can use the ‘logout’ sequence to simulate a session timeout (Use Remove authenticated user Step) and the execute ‘next’ sequence to see difference.

    You can test it directly executing sequences in Studio but it will be more relevant to launch the simple web UI I made via a browser :
    http://localhost:18080/convertigo/projects/C8OForum134305/DisplayObjects/mobile/app.html

    In the project Explorer View of Convertigo Studio, have a look at app.html and custom.js files to see CTF workflow.

    Get the project here

    Support&QA

    • This reply was modified 5 years, 6 months ago by Gregory Vorbe.
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.