Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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,

like image 898
user888734 Avatar asked Jan 27 '16 15:01

user888734


1 Answers

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
}
like image 191
Sam FarajpourGhamari Avatar answered Nov 15 '22 08:11

Sam FarajpourGhamari