Logging in through a web api issues recording user details
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
bump. i'd appreciate help with this as soon as is possible. thank you
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