Beispiel #1
0
        public static bool ConfirmAccount(string userName, string accountConfirmationToken)
        {
            ExtendedMembershipProvider provider = VerifyProvider();

            Debug.Assert(provider != null); // VerifyProvider checks this
            return(provider.ConfirmAccount(userName, accountConfirmationToken));
        }
Beispiel #2
0
        public static bool ResetPassword(string passwordResetToken, string newPassword)
        {
            ExtendedMembershipProvider provider = VerifyProvider();

            Debug.Assert(provider != null); // VerifyProvider checks this
            return(provider.ResetPasswordWithToken(passwordResetToken, newPassword));
        }
Beispiel #3
0
        public static DateTime GetLastPasswordFailureDate(string userName)
        {
            ExtendedMembershipProvider provider = VerifyProvider();

            Debug.Assert(provider != null); // VerifyProvider checks this

            return(provider.GetLastPasswordFailureDate(userName));
        }
Beispiel #4
0
        public static int GetPasswordFailuresSinceLastSuccess(string userName)
        {
            ExtendedMembershipProvider provider = VerifyProvider();

            Debug.Assert(provider != null); // VerifyProvider checks this

            return(provider.GetPasswordFailuresSinceLastSuccess(userName));
        }
Beispiel #5
0
        public static bool IsAccountLockedOut(string userName, int allowedPasswordAttempts, TimeSpan interval)
        {
            ExtendedMembershipProvider provider = VerifyProvider();

            Debug.Assert(provider != null); // VerifyProvider checks this

            return(IsAccountLockedOutInternal(provider, userName, allowedPasswordAttempts, interval));
        }
Beispiel #6
0
        public static bool IsConfirmed(string userName)
        {
            ExtendedMembershipProvider provider = VerifyProvider();

            Debug.Assert(provider != null); // VerifyProvider checks this

            return(provider.IsConfirmed(userName));
        }
Beispiel #7
0
        public static int GetUserIdFromPasswordResetToken(string token)
        {
            ExtendedMembershipProvider provider = VerifyProvider();

            Debug.Assert(provider != null); // VerifyProvider checks this

            return(provider.GetUserIdFromPasswordResetToken(token));
        }
Beispiel #8
0
        public static string GeneratePasswordResetToken(string userName, int tokenExpirationInMinutesFromNow = 1440)
        {
            ExtendedMembershipProvider provider = VerifyProvider();

            Debug.Assert(provider != null); // VerifyProvider checks this

            return(provider.GeneratePasswordResetToken(userName, tokenExpirationInMinutesFromNow));
        }
Beispiel #9
0
        public static string CreateAccount(string userName, string password, bool requireConfirmationToken = false)
        {
            ExtendedMembershipProvider provider = VerifyProvider();

            Debug.Assert(provider != null); // VerifyProvider checks this

            return(provider.CreateAccount(userName, password, requireConfirmationToken));
        }
Beispiel #10
0
        private static ExtendedMembershipProvider VerifyProvider()
        {
            ExtendedMembershipProvider provider = Membership.Provider as ExtendedMembershipProvider;

            if (provider == null)
            {
                throw new InvalidOperationException(WebDataResources.Security_NoExtendedMembershipProvider);
            }
            provider.VerifyInitialized(); // Have the provider verify that it's initialized (only our SimpleMembershipProvider does anything here)
            return(provider);
        }
Beispiel #11
0
        public static string CreateUserAndAccount(string userName, string password, object propertyValues = null, bool requireConfirmationToken = false)
        {
            ExtendedMembershipProvider provider = VerifyProvider();

            Debug.Assert(provider != null); // VerifyProvider checks this

            IDictionary <string, object> values = propertyValues as RouteValueDictionary;

            if (values == null && propertyValues != null)
            {
                var propertyValuesAsDictionary = propertyValues as IDictionary <string, object>;
                if (propertyValuesAsDictionary != null)
                {
                    values = new RouteValueDictionary(propertyValuesAsDictionary);
                }
                else
                {
                    values = new RouteValueDictionary(propertyValues);
                }
            }

            return(provider.CreateUserAndAccount(userName, password, requireConfirmationToken, values));
        }
Beispiel #12
0
 internal static bool IsAccountLockedOutInternal(ExtendedMembershipProvider provider, string userName, int allowedPasswordAttempts, TimeSpan interval)
 {
     return(provider.GetUser(userName, false) != null &&
            provider.GetPasswordFailuresSinceLastSuccess(userName) > allowedPasswordAttempts &&
            provider.GetLastPasswordFailureDate(userName).Add(interval) > DateTime.UtcNow);
 }