No password = auto fail password checks

Rather than null ref boom...
This commit is contained in:
Hao Kung 2015-05-08 10:57:18 -07:00
parent 6814576b5e
commit f0098b6e1e
2 changed files with 5 additions and 0 deletions

View File

@ -669,6 +669,10 @@ namespace Microsoft.AspNet.Identity
protected virtual async Task<PasswordVerificationResult> VerifyPasswordAsync(IUserPasswordStore<TUser> store, TUser user, string password)
{
var hash = await store.GetPasswordHashAsync(user, CancellationToken);
if (hash == null)
{
return PasswordVerificationResult.Failed;
}
return PasswordHasher.VerifyHashedPassword(user, hash, password);
}

View File

@ -322,6 +322,7 @@ namespace Microsoft.AspNet.Identity.Test
var user = await manager.FindByNameAsync(username);
Assert.NotNull(user);
Assert.False(await manager.HasPasswordAsync(user));
Assert.False(await manager.CheckPasswordAsync(user, "whatever"));
var logins = await manager.GetLoginsAsync(user);
Assert.NotNull(logins);
Assert.Equal(0, logins.Count());