Existing user and email error message returned on register now.

This commit is contained in:
Steven Hildreth 2019-11-18 17:33:13 -06:00
parent e0208212a0
commit 82544c143b

View file

@ -199,6 +199,18 @@ namespace Roadie.Api.Controllers
}
}
var existinUserByUsername = await UserManager.FindByNameAsync(registerModel.Username);
if (existinUserByUsername != null)
{
return StatusCode((int)HttpStatusCode.BadRequest, new { Title = "User With Username Already Exists!" });
}
var existingUserByEmail = await UserManager.FindByEmailAsync(registerModel.Email);
if(existingUserByEmail != null)
{
return StatusCode((int)HttpStatusCode.BadRequest, new { Title = "User With Email Already Exists!" });
}
var identityResult = await UserManager.CreateAsync(user, registerModel.Password);
if (identityResult.Succeeded)
{