I'm trying to configure identity to work with custom provider. So far all good, I've created UserStore:
public class UserStore : IUserStore<User>, IUserPasswordStore<User>
(with all methods implemented) and UserManager:
public UserManager(IUserStore<User> userStore)
        : base(userStore)
    { }
and User is my custom entity to hold users.
The problem is that in UserStore I have the following:
public async Task SetPasswordHashAsync(User user, string passwordHash)
From what I have understood, this is called before user is created, so all I should do here is:
public Task SetPasswordHashAsync(User user, string passwordHash)
{
    user.PasswordHash = passwordHash;
}
... but this has to return a Task and I don't see anything asynchronous to be done here.
SetPasswordHashAsync and not just void?SetPasswordHashAsync?I know I can do something like
public async Task SetPasswordHashAsync(User user, string passwordHash)
{
    user.PasswordHash = passwordHash;
    await Task.FromResult(0);
}
... but isn't this synchronous? It is weird to see all other methods decorated with async Task and use await, and this one to return Task.FromResult()
Anyone?
Tasks do not have to be asynchronous. You can implement it as follows:
public Task SetPasswordHashAsync(User user, string passwordHash)
{
    user.PasswordHash = passwordHash;
    return Task.FromResult(0);
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With