List:Commits« Previous MessageNext Message »
From:rburnett Date:March 4 2009 8:18pm
Subject:Connector/NET commit: r1523 - in branches/5.2: . MySql.Web/Providers/Source MySql.Web/Tests
View as plain text  
Modified:
   branches/5.2/CHANGES
   branches/5.2/MySql.Web/Providers/Source/MembershipProvider.cs
   branches/5.2/MySql.Web/Tests/UserManagement.cs
Log:
- fixed Sql null value exception when an attempt was made to reset the password and 
  require question and answer was false.  (bug #41408)  


Modified: branches/5.2/CHANGES
===================================================================
--- branches/5.2/CHANGES	2009-03-04 19:33:44 UTC (rev 1522)
+++ branches/5.2/CHANGES	2009-03-04 20:18:35 UTC (rev 1523)
@@ -17,6 +17,8 @@
 - fixed problem with execution of LOAD DATA LOCAL INFILE (which also affected MySqlBulkLoader).
   When the driver encountered some type of error opening the local file for transport it would
   still attempt to close the file which would yield a null reference exception (bug #43332)      
+- fixed Sql null value exception when an attempt was made to reset the password and 
+  require question and answer was false.  (bug #41408)  
       
 Version 5.2.5 - 11/14/2008
 - fixed problem with package registration that kept the DDEX provider from working (bug #40726)

Modified: branches/5.2/MySql.Web/Providers/Source/MembershipProvider.cs
===================================================================
--- branches/5.2/MySql.Web/Providers/Source/MembershipProvider.cs	2009-03-04 19:33:44 UTC (rev 1522)
+++ branches/5.2/MySql.Web/Providers/Source/MembershipProvider.cs	2009-03-04 20:18:35 UTC (rev 1523)
@@ -954,16 +954,18 @@
                         if (reader.GetBoolean("IsLockedOut"))
                             throw new MembershipPasswordException(Resources.UserIsLockedOut);
 
-                        string passwordAnswer = reader.GetString("PasswordAnswer");
+                        object passwordAnswer = reader.GetValue(reader.GetOrdinal("PasswordAnswer"));
                         passwordKey = reader.GetString("PasswordKey");
                         format = (MembershipPasswordFormat)reader.GetByte("PasswordFormat");
                         reader.Close();
 
-                        if (RequiresQuestionAndAnswer &&
-                            !CheckPassword(answer, passwordAnswer, passwordKey, format))
+                        if (RequiresQuestionAndAnswer)
                         {
-                            UpdateFailureCount(userId, "PasswordAnswer", connection);
-                            throw new MembershipPasswordException(Resources.IncorrectPasswordAnswer);
+                            if (!CheckPassword(answer, (string)passwordAnswer, passwordKey, format))
+                            {
+                                UpdateFailureCount(userId, "PasswordAnswer", connection);
+                                throw new MembershipPasswordException(Resources.IncorrectPasswordAnswer);
+                            }
                         }
                     }
 

Modified: branches/5.2/MySql.Web/Tests/UserManagement.cs
===================================================================
--- branches/5.2/MySql.Web/Tests/UserManagement.cs	2009-03-04 19:33:44 UTC (rev 1522)
+++ branches/5.2/MySql.Web/Tests/UserManagement.cs	2009-03-04 20:18:35 UTC (rev 1523)
@@ -600,5 +600,27 @@
             bool worked = provider2.ValidateUser("foo", "bar!bar");
             Assert.AreEqual(false, worked);
         }
+
+        /// <summary>
+        /// Bug #41408	PasswordReset not possible when requiresQuestionAndAnswer="false"
+        /// </summary>
+        [Test]
+        public void ResetPassword()
+        {
+            provider = new MySQLMembershipProvider();
+            NameValueCollection config = new NameValueCollection();
+            config.Add("connectionStringName", "LocalMySqlServer");
+            config.Add("applicationName", "/");
+            config.Add("passwordStrengthRegularExpression", "bar.*");
+            config.Add("passwordFormat", "Clear");
+            config.Add("requiresQuestionAndAnswer", "false");
+            provider.Initialize(null, config);
+
+            MembershipCreateStatus status;
+            provider.CreateUser("foo", "bar!bar", null, null, null, true, null, out status);
+
+            MembershipUser u = provider.GetUser("foo", false);
+            string newpw = provider.ResetPassword("foo", null);
+        }
     }
 }

Thread
Connector/NET commit: r1523 - in branches/5.2: . MySql.Web/Providers/Source MySql.Web/Testsrburnett4 Mar