FormatException in custom IUserPasswordStore<Client> implementation

Apr 2, 2015 at 7:56 PM
Edited Apr 2, 2015 at 9:18 PM
I'm writing custom implementation of IUserPasswordStore<Client> but I got FormatException during login process. It seems like method GetPasswordHashAsync or someone who call this method calls Microsoft.AspNet.Identity.Crypto.VerifyHashedPassword(String hashedPassword, String password) which cause FormatException with message
Invalid length for a Base-64 char array or string.
Here is my implementation of IUserPasswordStore<Client>
public partial class ClientRepository : IUserStore<Client>, IUserPasswordStore<Client>, IUserLockoutStore<Client, string>
{
    public Task CreateAsync(Client user)
    {
        return Task.Factory.StartNew(() => Create(user));
    }

    public Task UpdateAsync(Client user)
    {
        return Task.Factory.StartNew(() => Update(user));
    }

    public Task DeleteAsync(Client user)
    {
        return Task.Factory.StartNew(() => Delete(user));
    }

    public Task<Client> FindByIdAsync(string userId)
    {
        return Task.FromResult(Find(userId));
    }

    public Task<Client> FindByNameAsync(string userName)
    {
        return Task.FromResult(FetchOne(new ClientByUsername(userName)));
    }

    public Task SetPasswordHashAsync(Client user, string passwordHash)
    {
        return Task.Factory.StartNew(() => user.Password = passwordHash);
    }

    public Task<string> GetPasswordHashAsync(Client user)
    {
        return Task.FromResult(user.Password);
    }

    public Task<bool> HasPasswordAsync(Client user)
    {
        return Task.Factory.StartNew(() => !string.IsNullOrEmpty(user.Password));
    }

    public Task<DateTimeOffset> GetLockoutEndDateAsync(Client user)
    {
        return Task.FromResult<DateTimeOffset>(user.LockoutTo ?? DateTime.Now);
    }

    public Task SetLockoutEndDateAsync(Client user, DateTimeOffset lockoutEnd)
    {
        return Task.Factory.StartNew(() => user.LockoutTo = lockoutEnd.DateTime);
    }

    public Task<int> IncrementAccessFailedCountAsync(Client user)
    {
        return Task.FromResult(++user.LoginAttempts);
    }

    public Task ResetAccessFailedCountAsync(Client user)
    {
        return Task.Factory.StartNew(() => user.LoginAttempts = 0);
    }

    public Task<int> GetAccessFailedCountAsync(Client user)
    {
        return Task.Factory.StartNew(() => user.LoginAttempts);
    }

    public Task<bool> GetLockoutEnabledAsync(Client user)
    {
        return Task.FromResult(false);
    }

    public Task SetLockoutEnabledAsync(Client user, bool enabled)
    {
        return Task.FromResult(0);
    }



    public void Dispose()
    {
        database = null;
        Manager = null;
        context = null;
    }
}
And my question: Where is called Microsoft.AspNet.Identity.Crypto.VerifyHashedPassword(String hashedPassword, String password) and what should I return in GetPasswordHashAsync? For start I'm using password in plain text...

Fixed: I have to use custom implementation of IPasswordHasher bcs I'm using passwords in plain text. :)
Marked as answer by SebastianBusek on 4/2/2015 at 2:17 PM