More in this section
Forums / Developing with Sitefinity / Logging in through a web api issues recording user details

Logging in through a web api issues recording user details

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
3 posts, 0 answered
  1. bryan
    bryan avatar
    10 posts
    Registered:
    11 Apr 2016
    16 Sep 2016
    Link to this post

    howdy, i am trying to block access to my site's api unless they're authenticated. i have a POST function that contains the following:

     if (manager.ValidateUser(username, password))
                    {
                        DateTime now = DateTime.UtcNow;
                        var user = manager.GetUser(username);

                        user.IsLoggedIn = true;
                        user.LastLoginIp = HttpContext.Request.UserHostAddress;
                        user.LastLoginDate = now;
                        user.LastActivityDate = now;

                        UserLoggingReason validate = SecurityManager.AuthenticateUser(UserManager.GetDefaultProviderName(), username, password, true, out user);

                        if (validate.Equals(UserLoggingReason.UserAlreadyLoggedIn))
                        {
                            SecurityManager.Logout(UserManager.GetDefaultProviderName(), user.Id);
                            validate = SecurityManager.AuthenticateUser(UserManager.GetDefaultProviderName(), username, password, true, out user);
                        }

                        if (validate.Equals(UserLoggingReason.Success))
                        {
                            manager.Provider.SuppressSecurityChecks = true;
                            manager.SaveChanges();
                        }

    The issue seems to lie in the manager.SaveChanges() spot as it attempts to save the minor changes to the user. The following error gets generated:

     

    Telerik.OpenAccess.Exceptions.OptimisticVerificationException: Row not found: GenericOID@e62cbf64 User id=977bacc3-79d6-6539-9d49-ff0000f4184f
            UPDATE [sf_users] SET [fld_psswrd_ttempt_window_start]=?, [is_logged_in]=?, [last_login_date]=?, [last_modified]=? WHERE [id] = ? AND [fld_psswrd_ttempt_window_start]=? AND [is_logged_in]=? AND [last_login_date]=? AND [last_modified]=?
                (set event logging to all to see parameter values)

     

    I have seen across multiple threads that i am not the only one with this issue but from what i've seen its a concurrency issue...but in my case i hit this error every time, and i'm the only one testing the function. So i've no idea how to get around this. Am i even using the correct sitefinity way to allow a script to login and access my api? Thank you

  2. bryan
    bryan avatar
    10 posts
    Registered:
    11 Apr 2016
    26 Sep 2016
    Link to this post
    bump. i'd appreciate help with this as soon as is possible. thank you
  3. bryan
    bryan avatar
    10 posts
    Registered:
    11 Apr 2016
    26 Oct 2016
    Link to this post
    hello, i asked this question during  what seemed like a rough period for these forums (seemed like heavy spamming was going on) and i've now come back to this project and need this question answered. I've seen this problem in a couple of forum posts but no real answers to any of them. Could someone please help? Thank you
3 posts, 0 answered