I am currently implementing the ability to login on my ASP.NET MVC project. I am trying to use as much of the provided methods as I can.
Currently, I have set up a table in my database known as User, which stores all the usernames, passwords and other details regarding the users.
My LoginViewModel:
public class LoginViewModel
{
public User User { get; set; }
}
The AccountController (which is mostly the default, I have only changed the variables of the PasswordSignInAsync method)
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
if (ModelState.IsValid)
{
return View(model);
}
// To enable password failures to trigger account lockout, change to shouldLockout: true
var result = await SignInManager.PasswordSignInAsync(model.User.Username, model.User.Password, false , shouldLockout: false);
Why does this line always return a Failure?
It's my first time trying to add the Login ability, so any help would be greatly appreciated. :)
Add
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
To method public void ConfigureAuth(IAppBuilder app)
in App_Start\Startup.Auth.cs