Próbuję skonfigurować uwierzytelnianie i autoryzację przy użyciu mojej istniejącej bazy danych i tabel, bez korzystania z Entity Framework (przy użyciu Dappera).Uwierzytelnianie i autoryzacja bez struktury encji w ASP.NET 5 MVC 6
Mam poprawnie skonfigurowany Dapper, teraz próbuję podłączyć SignInManager i UserManager, aby zadzwonić do mojej bazy danych przez Dapper, ale zanim to się stanie, mam pewne błędy z moją niestandardową rolą sklep.
Tutaj jest błąd, który ja dostaję po kliknięciu przycisku „Rejestracja” na stronie internetowej (jest to po prostu zwykły projekt ze wszystkimi wstępnie zdefiniowane konta itp rzeczy z pudełka)
InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNet.Identity.IRoleStore`1[TestAsyncWebsite.Configuration.WrestleStatRole]' while attempting to activate 'Microsoft.AspNet.Identity.RoleManager`1[TestAsyncWebsite.Configuration.WrestleStatRole]'
Na razie, oto jak mam skonfigurowany moich zwyczaj użytkownik, rola, userstore, sklep rola, usermanager i rolemanager:
public class WrestleStatUser : ApplicationUser
{
public WrestleStatUser() : base()
{
}
}
public class WrestleStatRole : IdentityRole
{
}
public class WrestleStatUserStore : IUserStore<WrestleStatUser>
{
// all methods implemented
}
public class WrestleStatRoleStore : IRoleStore<WrestleStatRole>
{
// all methods implemented
}
public class WrestleStatUserManager : UserManager<WrestleStatUser>
{
public WrestleStatUserManager(IUserStore<WrestleStatUser> store, IOptions<IdentityOptions> optionsAccessor, IPasswordHasher<WrestleStatUser> passwordHasher, IEnumerable<IUserValidator<WrestleStatUser>> userValidators, IEnumerable<IPasswordValidator<WrestleStatUser>> passwordValidators, ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, IEnumerable<IUserTokenProvider<WrestleStatUser>> tokenProviders, ILogger<UserManager<WrestleStatUser>> logger, IHttpContextAccessor contextAccessor)
: base(store, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, tokenProviders, logger, contextAccessor)
{
}
}
public class WrestleStatRoleManager : RoleManager<WrestleStatRole>
{
public WrestleStatRoleManager(IRoleStore<WrestleStatRole> store, IEnumerable<IRoleValidator<WrestleStatRole>> roleValidators, ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, ILogger<RoleManager<WrestleStatRole>> logger, IHttpContextAccessor contextAccessor) : base(store, roleValidators, keyNormalizer, errors, logger, contextAccessor)
{
}
}
i tu jest moje startup.cs:
services.AddIdentity<WrestleStatUser, WrestleStatRole>()
.AddUserStore<WrestleStatUserStore>()
.AddUserManager<WrestleStatUserManager>()
//.AddRoleStore<RoleStore>()
.AddRoleManager<WrestleStatRoleManager>()
.AddDefaultTokenProviders();
Czego mi tu brakuje? Błąd mówi coś o RoleManager, już zdefiniowałem mój niestandardowy RoleManager ...