Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove magic strings for MeApiController #2340

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions AllReadyApp/Web-App/AllReady/Controllers/MeApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ namespace AllReady.Controllers
[Route("api/me")]
public class MeApiController : Controller
{
private const string INVALID_LOGIN = "Unable to validate login information";
private const string TWO_FACTOR_NOT_SUPPORTED = "2 factor not supported yet!";
private const string ACCOUNT_LOCKED_OUT = "Account is locked out. Please try again later";

private readonly UserManager<ApplicationUser> _userManager;
private readonly SignInManager<ApplicationUser> _signInManager;
private readonly IMediator _mediator;
Expand All @@ -35,7 +39,7 @@ public async Task<IActionResult> Login([FromBody] LoginViewModel model)
{
if (!ModelState.IsValid)
{
return BadRequest("Unable to valid login information");
return BadRequest(INVALID_LOGIN);
}

// Require admin users to have a confirmed email before they can log on.
Expand All @@ -61,17 +65,17 @@ public async Task<IActionResult> Login([FromBody] LoginViewModel model)

if (result.RequiresTwoFactor)
{
return BadRequest("2 factor not supported yet!");
return BadRequest(TWO_FACTOR_NOT_SUPPORTED);

}

if (result.IsLockedOut)
{
//return View("Lockout");
return BadRequest("Account is locked out. Please try again later");
return BadRequest(ACCOUNT_LOCKED_OUT);
}

return Unauthorized();
}
}
}
}