Unable to resolve service for type ‘Microsoft.AspNetCore.Identity.UserManager` while attempting to activate ‘AuthController’

You need to use the same user data model in SignInManager, UserManager and services.AddIdentity. Same principal is true if you are using your own custom application role model class. So, change services.AddIdentity<IdentityUser, IdentityRole>(options => { options.User.RequireUniqueEmail = false; }) .AddEntityFrameworkStores<Providers.Database.EFProvider.DataContext>() .AddDefaultTokenProviders(); to services.AddIdentity<Automobile.Models.Account, IdentityRole>(options => { options.User.RequireUniqueEmail = false; }) .AddEntityFrameworkStores<Providers.Database.EFProvider.DataContext>() .AddDefaultTokenProviders();

How to load navigation properties on an IdentityUser with UserManager

Unfortunately, you have to either do it manually or create your own IUserStore<IdentityUser> where you load related data in the FindByEmailAsync method: public class MyStore : IUserStore<IdentityUser>, // the rest of the interfaces { // … implement the dozens of methods public async Task<IdentityUser> FindByEmailAsync(string normalizedEmail, CancellationToken token) { return await context.Users .Include(x => x.Address) … Read more

How to give custom implementation of UpdateAsync method of asp.net identity?

Not sure if this is what your looking for… public Task UpdateAsync(UserModel model) { var user = _dbContext.User.Find(x => x.id == model.id); user.Password = model.Password; _dbContext.SaveChanges(); return Task.CompletedTask; } It Will get the specific record and Update the password and then save the record. Edit Since the password is not getting encrypted i added code … Read more

ASP.NET Core Identity 2.0 SignoutAsync is not logging out user if the user signed in with Google

The problem is that your RedirectToAction overwrites the redirect to the Identity Server endsession URL that SignOutAsync issues. As for SignOutAsync, what is obsolete is the Authentication portion — as of ASP.NET Core 2.0 it’s an extension directly off HttpContext itself. (The same explanation for the same signout problem is given here by Microsoft’s HaoK.) … Read more

Multiple Identities in ASP.NET Core 2.0

After looking through the ASP.NET Core source code on github, a second identity could be added using this extension method: using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using System; using System.Collections.Generic; using System.Text; namespace Whatever { public static class IdentityExtensions { public static IdentityBuilder AddSecondIdentity<TUser, TRole>( this IServiceCollection services) where TUser : class where TRole : … Read more

Asp.net core Identity successful login redirecting back to login page

In order to get the ASP.NET Core pipeline to recognise that a user is signed in, a call to UseAuthentication is required in the Configure method of your Startup class, like so: app.UseAuthentication(); app.UseMvc(); // Order here is important (explained below). Using the Cookies authentication scheme, the use of UseAuthentication loosely performs the following: Reads … Read more

.NET Core 2.1 Identity get all users with their associated roles

I have now implemented the following solution. As CodeNotFound pointed out in the comments, IdentityUser used to have a Roles property. This is no longer the case in .NET Core. This comment/issue on GitHub seems to be the current solution for .Net Core. I have attempted to implemented it with the following code: ApplicationUser public … Read more