user888734
user888734

Reputation: 3897

UserManager.FindAsync(username, password) not available in ASP.NET 5 / Identity 3

I'm trying to upgrade a project to ASP.NET 5 / MVC 6.

The UserManager that came with AspNet.Identity used to have a FindAsync method where I could pass in a username and password. It doesn't seem to be there anymore.

I don't think I need the SigninManager or Authentication as I'm using JWT Bearer Authentication. I just need to check the username and password are valid before I grant an access token,

Upvotes: 6

Views: 4121

Answers (2)

Sam FarajpourGhamari
Sam FarajpourGhamari

Reputation: 14741

Simply use UserManager.FindByNameAsync() to find the user object then check its password:

var user = await _userManager.FindByNameAsync(userName);
if(user!=null && await _userManager.CheckPasswordAsync(user, password))
{
    // user is valid do whatever you want
}

Upvotes: 15

Joe Audette
Joe Audette

Reputation: 36696

It looks like it has been renamed to:

public virtual Task<TUser> FindByNameAsync(string userName)

you can view the source code for UserManager here

Upvotes: 0

Related Questions