Ejemplo n.º 1
0
 protected void Update(XElement xUser, XElement xSecurityEntry)
 {
     Modifier.AppendUpdate(xUser);
     Modifier.AppendCreate(xSecurityEntry);
     Modifier.Persist();
     Modifier.Clear();
 }
Ejemplo n.º 2
0
        protected void UpdateLockedOutState(XElement user, bool isSuccessful)
        {
            DateTime           now                = ODataQuerier.GetNow();
            string             nowString          = new DotNETDateFormatter().Format(now);
            SettingsService    settingsService    = new SettingsService(Name);
            MembershipSettings membershipSettings = settingsService.GetMembershipSettings();

            if (isSuccessful)
            {
                user.SetElementValue("LastLoginDate", nowString);
                user.SetElementValue("FailedPasswordAttemptCount", 0);
            }
            else
            {
                if (membershipSettings.MaxInvalidPasswordAttempts == 0)
                {
                    return;
                }

                int failedCount = int.Parse(user.Element("FailedPasswordAttemptCount").Value);
                if (failedCount > 0)
                {
                    DateTime start = DateTime.Parse(user.Element("FailedPasswordAttemptWindowStart").Value);
                    if ((DateTime.Now - start).TotalMinutes < membershipSettings.PasswordAttemptWindow)
                    {
                        if (failedCount >= membershipSettings.MaxInvalidPasswordAttempts)
                        {
                            user.SetElementValue("IsLockedOut", true.ToString());
                            user.SetElementValue("LastLockoutDate", nowString);
                        }
                        else
                        {
                            failedCount++;
                            user.SetElementValue("FailedPasswordAttemptCount", failedCount);
                        }
                    }
                    else
                    {
                        user.SetElementValue("FailedPasswordAttemptCount", 1);
                        user.SetElementValue("FailedPasswordAttemptWindowStart", nowString);
                    }
                }
                else
                {
                    user.SetElementValue("FailedPasswordAttemptCount", 1);
                    user.SetElementValue("FailedPasswordAttemptWindowStart", nowString);
                }
            }
            Modifier.AppendUpdate(user);
        }
Ejemplo n.º 3
0
 public static void AppendUpdate(this Modifier <XElement> modifier, XElement element, XElement original, XElement schema)
 {
     modifier.AppendUpdate(element, original, element.Name.LocalName, schema);
 }