当前位置: 首页>>代码示例>>C#>>正文


C# UserRepository.UnlockAccount方法代码示例

本文整理汇总了C#中UserRepository.UnlockAccount方法的典型用法代码示例。如果您正苦于以下问题:C# UserRepository.UnlockAccount方法的具体用法?C# UserRepository.UnlockAccount怎么用?C# UserRepository.UnlockAccount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserRepository的用法示例。


在下文中一共展示了UserRepository.UnlockAccount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UnlockUser

        public override bool UnlockUser(string username)
        {
            SecUtility.CheckParameter(ref username, true, true, true, 256, "username");
            var dbo = new UserRepository(this.Name, _sqlConnectionString, _commandTimeout);
            var user = dbo.GetUser(username);
            if (user == null)
                return false;

            return dbo.UnlockAccount(username);
        }
开发者ID:cwbrandsma,项目名称:OpenId-Provider,代码行数:10,代码来源:UnityMembershipProvider.cs

示例2: CheckPassword

        private bool CheckPassword(string username, string password, bool updateLastLoginActivityDate, bool failIfNotApproved, out string salt, out int passwordFormat)
        {
            string passwdFromDB;
            int status;
            int failedPasswordAttemptCount;
            int failedPasswordAnswerAttemptCount;
            bool isApproved;
            DateTime lastLoginDate, lastActivityDate;

            GetPasswordWithFormat(username, updateLastLoginActivityDate, out status, out passwdFromDB, out passwordFormat, out salt, out failedPasswordAttemptCount,
                                  out failedPasswordAnswerAttemptCount, out isApproved, out lastLoginDate, out lastActivityDate);
            if (status != 0)
                return false;
            if (!isApproved && failIfNotApproved)
                return false;

            string encodedPasswd = EncodePassword(password, passwordFormat, salt);

            bool isPasswordCorrect = passwdFromDB.Equals(encodedPasswd);

            if (isPasswordCorrect && failedPasswordAttemptCount == 0 && failedPasswordAnswerAttemptCount == 0)
                return true;

            var dbo = new UserRepository(this.Name, _sqlConnectionString, _commandTimeout);
            var user = dbo.GetUser(username);

            // set out parameters
            passwordFormat = (int)user.PasswordFormat;
            salt = user.Salt;
            if (user.IsLockedOut)
                return false;

               DateTime dtNow = DateTime.UtcNow;

            if (!isPasswordCorrect)
            {
                user.FailedPasswordAnswerAttemptWindowStart = user.FailedPasswordAnswerAttemptWindowStart ?? DateTime.UtcNow.AddYears(-2);
                if (dtNow > user.FailedPasswordAnswerAttemptWindowStart.Value.AddMinutes(_passwordAttemptWindow))
                {
                    dbo.PasswordAttemptCountClear(username);
                }
                dbo.FailedPasswordAttemptIncrement(username);

                if (user.FailedPasswordAnswerAttemptCount.GetValueOrDefault() >= failedPasswordAnswerAttemptCount)
                {
                    dbo.LockAccount(username);
                }
            }
            else
            {
                if (user.FailedPasswordAnswerAttemptCount.GetValueOrDefault() > 0 || user.FailedPasswordAnswerAttemptCount.GetValueOrDefault() > 0)
                {
                    dbo.UnlockAccount(username);
                }
            }

            dbo.UpdateLastActivityDate(username);

            return isPasswordCorrect;
        }
开发者ID:cwbrandsma,项目名称:OpenId-Provider,代码行数:60,代码来源:UnityMembershipProvider.cs


注:本文中的UserRepository.UnlockAccount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。