Questions tagged [asp.net-core-identity]

Use ASP.NET Core Identity to add login functionality to an ASP.NET Core application.

887 questions
112
votes
7 answers

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

I'm getting this error in Login Controller. InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UserManager`1[Automobile.Models.Account]' while attempting to activate…
OMID
  • 1,839
  • 4
  • 13
  • 23
54
votes
5 answers

How override ASP.NET Core Identity's password policy

By default, ASP.NET Core Identity's password policy require at least one special character, one uppercase letter, one number, ... How can I change this restrictions ? There is nothing about that in the documentation…
52
votes
2 answers

.NET Core Identity vs IdentityServer4

The question: Should I use .Net Core Identity or IdentityServer 4 with Identity I need to build app with login/register functionality and allow users to use APIs to import/export data from my software. I also want to have external logins like…
ferdinand
  • 748
  • 1
  • 6
  • 13
49
votes
12 answers

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

I'm trying to pull out all my Identity users and their associated roles for a user management admin page. I thought this would be reasonably easy but apparently not. I've tried following the following solution:…
49
votes
11 answers

ASP.NET Core 2.0 JWT Validation fails with `Authorization failed for user: (null)` error

I'm using ASP.NET Core 2.0 application (Web API) as a JWT issuer to generate a token consumable by a mobile app. Unfortunately, this token couldn't be validated by one controller while can be validated by another (using the same validation setting…
35
votes
3 answers

How to load navigation properties on an IdentityUser with UserManager

I've extended IdentityUser to include a navigation property for the user's address, however when getting the user with UserManager.FindByEmailAsync, the navigation property isn't populated. Does ASP.NET Identity Core have some way to populate…
Mourndark
  • 2,192
  • 3
  • 24
  • 42
33
votes
8 answers

How to return 401 instead of 302 in ASP.NET Core?

I'm trying to get ASP.NET Core Identity to return 401 when a user isn't logged in. I've added an [Authorize] attribute to my method and instead of returning 401 it returns 302. I've tried a ton of suggestions but nothing seems to work, including…
Eric B
  • 4,077
  • 5
  • 29
  • 39
27
votes
3 answers

NormalizedUserName VS Username in DotNet Core

I'm trying to create a custom implementation of IUserLoginStore for MongoDB and I noticed when using UserManager with the method var userResult = await _userManager.CreateAsync(user); it goes through the implementation of…
pedrommuller
  • 14,865
  • 9
  • 65
  • 115
27
votes
6 answers

How should I access my ApplicationUser properties from ASP.NET Core Views?

I'm working on an ASP.Net vNext / MVC6 project. I'm getting to grips with ASP.Net Identity. The ApplicationUser class is apparently where I'm supposed to add any additional user properties, and this works with Entity Framework and my additional…
Tim Long
  • 13,000
  • 18
  • 75
  • 141
26
votes
6 answers

Change routing in ASP.NET Core Identity UI?

I am using the new Identity UI package available since ASP.NET Core 2.1 was released. Using a newly generated MVC project, here are some page URLs that are available: /Home/About /Home/Contact /Identity/Account/Login /Identity/Account/Register How…
Phil K
  • 3,745
  • 4
  • 26
  • 48
26
votes
3 answers

How to mock UserManager in .Net Core testing?

I have following code. Im trying to running a test case for create user.Following is what i have tried so far. public class CreateUserCommandHandlerTest { private Mock> _userManager; private…
23
votes
1 answer

UserManager.CheckPasswordAsync vs SignInManager.PasswordSignInAsync

using asp net core identity - when user provides password and username to get a jwt token they post credentials to /api/token should my token controller method be using usermanager to check the password using the CheckPasswordAsync and if this…
JimmyShoe
  • 1,379
  • 10
  • 35
23
votes
1 answer

Using AspNetUserTokens table to store refresh token in ASP.NET Core Web Api

I'm working with ASP.NET Core Web API application. I'm trying to implement Jwt Token Based Authentication on top of ASP.NET Identity( built in with database tables). I have implemented all scenarios like register user, login etc but now trying to…
21
votes
1 answer

.NetCore JwtBearerAuthentication not rejecting expired tokens

I am generating JWT's to use with my WebApi project. I'm set the token to expire in one minute so that I can test if it rejects the token when submitted after the expiration date. CreateToken Controller public async Task
Dblock247
  • 4,603
  • 6
  • 35
  • 61
20
votes
2 answers

Asp.net Core Get User by User Id

Using Asp.net Core Identity and entity framework core, how can I get an asp.net user object by it's UserId property? I know it's possible to get the current logged in user from the HttpContext.User object…
big_water
  • 2,232
  • 2
  • 18
  • 37
1
2 3
59 60