locked
User state help - "invitation sent, LIVE, Logged in" RRS feed

  • Question

  • User-570626059 posted

    Hello,

    currently when a new user is registered their status is set to "Invite sent" and they get an email. 

    When this user logs in for the first time their status field is set to "LIVE" because they have now become live...

    all works ok.

    However my requirement is when the user logs in I want their status to be "Logged In" and when "Logged out" I want it to revert back to LIVE.

    how can i do this?

    Wednesday, July 4, 2018 2:22 PM

All replies

  • User475983607 posted

    skyblue28

    However my requirement is when the user logs in I want their status to be "Logged In" and when "Logged out" I want it to revert back to LIVE.

    how can i do this?

    Kinda' but there is just no way to know when a user stops using a web application.  The common approach is to log the last access time.  If the the current time is greater than the last access time plus the auth token timeout, then the user is logged out.

    Wednesday, July 4, 2018 3:06 PM
  • User-570626059 posted

    Ok i see what you mean, how do I get the token timeout? i am using identity?

    And I would just have this check on my master page which would perform the db updates and set the new status?

    Wednesday, July 4, 2018 3:37 PM
  • User475983607 posted

    Ok i see what you mean, how do I get the token timeout? i am using identity?

    The default is 20 minutes otherwise it is the value you set in the OWIN setup.

    And I would just have this check on my master page which would perform the db updates and set the new status?

    Sure or a base page or the global.asax.

    Wednesday, July 4, 2018 3:46 PM
  • User-570626059 posted
    So the last user logged in time - 20mins will tell me if the user is still logged in?

    So after timeout the user is automatically kicked out and has to log in again?

    Wednesday, July 4, 2018 4:37 PM
  • User475983607 posted

    So the last user logged in time - 20mins will tell me if the user is still logged in?

    Logically, if the auth token (or cookie) timeout is 20 minutes, and the user has not visited the site for 20 minutes then the user will need to login the next time the user requests a page.

    So after timeout the user is automatically kicked out and has to log in again?

    Sort of, the auth token is stored in a cookie.  The auth cookie has an expiration.  Browsers delete expired cookies.  The token inside the cookie also has an expiration.  If the token is expired, the Identity framework will force the user to login.  The default cookie and token expiration are 20 minutes.

    I suppose you could do something fancy with Session expiration or a memory cache as both frameworks have a timeout handler that runs on the server.  However, this can limit the how the application scales out.

    IMHO, it seems like over engineering.  Can you explain the requirement?

    Wednesday, July 4, 2018 4:57 PM
  • User-570626059 posted
    Ok brilliant. Sorry new to .net.

    I have users which belong to suppliers. The supplier statuses will be the same as the users.


    Basically when user is set up they get an email. I set their status as "invited"

    On first logon I set status to "logged in"

    And whenever user is not logged in I need to set status back to "live" to show the account as live but not logged in.

    Then the admin can see on the dashbaord all users and their corresponding statuses

    Then I will check all users for each supplier and if any are logged in then also set the supplier status as logged in and the same for the other statuses.

    Wednesday, July 4, 2018 5:10 PM
  • User475983607 posted

    Ok brilliant. Sorry new to .net.

    Nothing to do with .NET.  This is Web Developer 101 stuff and the same problem exists regardless of the framework being used.

    Basically when user is set up they get an email. I set their status as "invited"

    On first logon I set status to "logged in"

    And whenever user is not logged in I need to set status back to "live" to show the account as live but not logged in.

    Then the admin can see on the dashbaord all users and their corresponding statuses

    Then I will check all users for each supplier and if any are logged in then also set the supplier status as logged in and the same for the other statuses.

    The common approach, as stated above, is to log the DateTime on each request in the Uset table.  Active user are one where the last access time is within 20 minutes.  IMHO, you're mixing account registration with determining if a user is currently active or not.  Over engineering...

    Wednesday, July 4, 2018 5:44 PM