BetterMembership.Web.BetterMembershipProvider.ResetPassword C# (CSharp) Метод

ResetPassword() публичный Метод

public ResetPassword ( string userName, string answer ) : string
userName string
answer string
Результат string
        public override string ResetPassword(string userName, string answer)
        {
            Condition.Requires(userName, "userName").IsNotNullOrEmpty();

            if (!string.IsNullOrWhiteSpace(answer))
            {
                throw new NotSupportedException("answer is not supported, pass an empty string or null");
            }

            var newPassword =
                Membership.GeneratePassword(
                    this.MinRequiredPasswordLength < PasswordSize ? PasswordSize : this.MinRequiredPasswordLength, 
                    this.MinRequiredNonAlphanumericCharacters);

            if (!this.HasLocalAccount(this.GetUserId(userName)))
            {
                this.CreateAccount(userName, newPassword, false);
                return newPassword;
            }

            return this.ResetPasswordAndUnlock(userName, newPassword) ? newPassword : null;
        }

Usage Example

        public void GivenProviderWhenResetPasswordWithAnswerThenNotSupportedException()
        {
            // arrange
            var provider = new BetterMembershipProvider();

            // act // assert
            Assert.Throws<NotSupportedException>(() => provider.ResetPassword("username", "not null"));
        }