Token based login logic change in ASP.NET Identity 2.0

Achinth Gurkhi

I am building a SPA app using WebAPI 2 backend. I am using the new ASP.NET Identity 2.0 for authorization and authentication. To login I call the /Token URL which returns the token which I use for subsequent API calls. Now all this works fine.

Now I need to make some changes to the login/authentication process where I want to check if email is confirmed and also the user is active (both DB fields) before returning the token. But I am unable to find which method is being called for authorization. I thought it was the GetExternalLogin method in AccountController but it does not seem to be so.

Can someone tell me where I need to change the login logic?

sunil

You will need to implement your own UserStore to implement your own authentication logic.
Refer This SO question

If you don't want to do that may be, in ApplicationOAuthProvider.cs find this function GrantResourceOwnerCredentials. After this line

IdentityUser user = await userManager.FindAsync(context.UserName, 
                                                context.Password); 

you may be able to squeeze in some custom logic like

if (IsEmailConfirmed(user) == false)
{
   context.SetError("invalid_grant", "The user name or password is incorrect.");
   return;
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

ASP.NET MVC 5 Identity 2 Login redirect based on user role

How to change user login credentials in identity asp.net mvc?

Change identity login URL in ASP.net core 3.0

Asp.NET Identity 2 giving "Invalid Token" error

How to refresh CSRF token on login when using cookie authentication without identity in ASP .NET Core Web API

How To Change Password Validation in ASP.Net MVC Identity 2?

Why sign-in a new user when using ASP.NET Core Identity and token-based auth?

Verify Access Token - Asp.Net Identity

Asp net Core Identity token authentication expiration

Invalidate Asp Net Identity Jwt Token

Asp.net Identity 2.0 - redirect externally authenticated user based on role at login

ASP.Net Identity - cannot login with password

ASP.Net MVC Alternative Login to identity

Change default identity Login route to something custom asp.net core

Token Based Authentication in Asp.Net Core 2

ASP.net Identity Login trigger on Click of Login

Role based tokens ASP.net Identity

Cannot login on ASP.NET Identity 2 site after programmatic user creation

ASP.NET Identity 2 with Google login... Logout doesn't work

ASP.NET Identity 2 Separation of Email and UserName and using Email to login

ASP.NET Identity change password

Token Based Authentication in ASP.NET Core

ASP.NET Identity WebAPI invalid password reset token

ASP.NET Core Identity invalid token on confirmation email

ASP.NET Identity Bearer Token vs JWT Pros and Cons

What are a security token and security stamp in ASP.NET Identity?

ASP.NET Identity 2.0 Invalid Token Randomly

ASP.NET Identity Phone Number Token lifespan and SMS limit

Token invalid on reset password with ASP.NET Identity