Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #3 from appharbor/provide-less-specific-error-message

provide less specific error message
  • Loading branch information...
commit 02662c709468a66b0afbb28156c8204e2cbc24be 2 parents 2a29d95 + f4aa3c6
@mehrdada mehrdada authored
Showing with 3 additions and 2 deletions.
  1. +3 −2 AuthenticationExample.Web/Controllers/SessionController.cs
View
5 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,7 +35,7 @@ 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);
}
}
@@ -42,7 +43,7 @@ public ActionResult Create(SessionViewModel sessionViewModel)
{
if (!BCrypt.Net.BCrypt.Verify(sessionViewModel.Password, user.Password))
{
- ModelState.AddModelError("Password", "Wrong password");
+ ModelState.AddModelError(string.Empty, errorMessage);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.