In the template project generated by visual studio for ASP.NET identity authentication for Web Api 2 project, I added a class ApplicationUserStore(thats my custom userstore)
public class ApplicationUserStore : IUserStore<ApplicationUser>
{
private readonly ApplicationDbContext _context;
public ApplicationUserStore(ApplicationDbContext context)
{
_context = context;
}
public async Task<ApplicationUser> FindByIdAsync(string userName)
{
return await _context.Users.Include(x => x.FMBP_Company).FirstOrDefaultAsync(n => n.UserName == userName);
}
public Task CreateAsync(ApplicationUser user)
{
throw new NotImplementedException();
}
public Task DeleteAsync(ApplicationUser user)
{
throw new NotImplementedException();
}
public Task<ApplicationUser> FindByNameAsync(string userName)
{
return _context.Users.Include(x => x.FMBP_Company).FirstOrDefaultAsync(n => n.UserName == userName);
}
public Task UpdateAsync(ApplicationUser user)
{
throw new NotImplementedException();
}
public void Dispose()
{
throw new NotImplementedException();
}
}
I basically did this because I wanted FMBP_Company object whenever I do FindByIdAsync.
I even changed IdentiyConfig.cs and added following line so that I can use my custom userstore.
var manager = new ApplicationUserManager(new ApplicationUserStore(context.Get<ApplicationDbContext>()));
Once I did this, I am getting an error while doing registration.Following is the error.
Store does not implement IUserPasswordStore
ApplicationUserStore
to implement theIUserPasswordStore
interface? You would then havepublic class ApplicationUserStore : IUserStore<ApplicationUser>, IUserPasswordStore<ApplicationUser>
– Sanctimonious