Base solution for your next web application
Open Closed

Prevent multiple login with same user #1918


User avatar
0
kythor created

Hi,

Since we are offering livestreaming on our site, we would like to prevent viewers to login with the same user credentials at the same time. Is there a simple solution in your architecture to do this?

Idealy it would be something like this:

User A - Login with his credentials User B - Login with User A credentials at the same time => redirect to login page with message "Allready Logged in"


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    There is nothing build-in for doing this in AspNet Zero. You have to do it manually.

    I made a quick search and found this example <a class="postlink" href="http://stackoverflow.com/questions/27769860/aspnet-identity-avoid-simultaneous-login-same-account">http://stackoverflow.com/questions/2776 ... me-account</a>

    Which is also asked here <a class="postlink" href="https://github.com/aspnet/Identity/issues/308">https://github.com/aspnet/Identity/issues/308</a> and referenced implementation is here <a class="postlink" href="https://aspnet.codeplex.com/SourceControl/latest#Samples/Identity/SingleSignOutSample/SingleSignOutSample/App_Start/Startup.Auth.cs">https://aspnet.codeplex.com/SourceContr ... up.Auth.cs</a>

    But I didn't try this, you can give it a try.

  • User Avatar
    0
    douglasbustos created

    I am trying that, but doesnt work. Please help me.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Then you can try something else. Current User entity has a field named LastLoginTime. You can also add LastLogoutTime to user entity. See extending entities documetn for that <a class="postlink" href="https://aspnetzero.com/Documents/Extending-Existing-Entities">https://aspnetzero.com/Documents/Extend ... g-Entities</a>.

    Then, set LastLogoutTime when user logs out. Check Last Login and Logout Times when a user tries to login and allow or reject the login operation according to last login & logout time values.