Update password field in db, set null for uninitialized

This commit is contained in:
2013-02-12 20:22:49 -05:00
parent e2498b5270
commit 709ec249a2
8 changed files with 83 additions and 15 deletions
+12 -8
View File
@@ -8,6 +8,8 @@ namespace MileageTraker.Web.DAL
{
public class CodeFirstMembershipProvider : MembershipProvider
{
public const string UninitializedPassword = "uninitialized_state";
#region Properties
public override string ApplicationName
@@ -68,19 +70,17 @@ namespace MileageTraker.Web.DAL
status = MembershipCreateStatus.InvalidUserName;
return null;
}
if (string.IsNullOrEmpty(password))
{
status = MembershipCreateStatus.InvalidPassword;
return null;
}
if (string.IsNullOrEmpty(email))
{
status = MembershipCreateStatus.InvalidEmail;
return null;
}
var hashedPassword = Crypto.HashPassword(password);
if (hashedPassword.Length > 128)
string hashedPassword = null;
if (password != UninitializedPassword)
hashedPassword = Crypto.HashPassword(password);
if (hashedPassword != null && hashedPassword.Length > 128)
{
status = MembershipCreateStatus.InvalidPassword;
return null;
@@ -143,7 +143,11 @@ namespace MileageTraker.Web.DAL
throw new UserLockedOutException();
}
var hashedPassword = user.Password;
var verificationSucceeded = (hashedPassword != null && Crypto.VerifyHashedPassword(hashedPassword, password));
if (hashedPassword == null)
throw new UninitializedAccountException();
var verificationSucceeded =Crypto.VerifyHashedPassword(hashedPassword, password);
if (verificationSucceeded)
{
user.PasswordFailuresSinceLastSuccess = 0;