コード例 #1
0
ファイル: AccountService.cs プロジェクト: shantiw/mini
        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);
        }
コード例 #2
0
 public static DateTime GetNow(string name)
 {
     return(ODataQuerier.GetNow(name));
 }
コード例 #3
0
 public DateTime GetNow()
 {
     return(ODataQuerier.GetNow());
 }