Permalink
Browse files

provide less specific error message

  • Loading branch information...
1 parent 19ee344 commit f4aa3c6ccf337245eddfd5a6fb74714b68a530e3 @friism friism committed Aug 14, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 AuthenticationExample.Web/Controllers/SessionController.cs
@@ -12,6 +12,7 @@ public class SessionController : Controller
{
private readonly IAuthenticator _authenticator;
private readonly IRepository _repository;
+ private const string errorMessage = "Invalid username or password";
public SessionController(IAuthenticator authenticator, IRepository repository)
{
@@ -34,15 +35,15 @@ public ActionResult Create(SessionViewModel sessionViewModel)
user = _repository.GetAll<User>().SingleOrDefault(x => x.Username == sessionViewModel.Username);
if (user == null)
{
- ModelState.AddModelError("Username", "User not found");
+ ModelState.AddModelError(string.Empty, errorMessage);
}
}
if (ModelState.IsValid)
{
if (!BCrypt.Net.BCrypt.Verify(sessionViewModel.Password, user.Password))
{
- ModelState.AddModelError("Password", "Wrong password");
+ ModelState.AddModelError(string.Empty, errorMessage);
}
}

0 comments on commit f4aa3c6

Please sign in to comment.