diff options
-rw-r--r-- | Controllers/UsersController.cs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Controllers/UsersController.cs b/Controllers/UsersController.cs index 5483a6b..9e66fce 100644 --- a/Controllers/UsersController.cs +++ b/Controllers/UsersController.cs @@ -26,11 +26,13 @@ namespace IdentityAPI.Controllers { [HttpPost("signup")] public async Task<IActionResult> SignUp(UserDTO data) { - var user = new IdentityUser { UserName = data.UserName, Email = data.Email }; - var result = await _manager.CreateAsync(user, data.Password); + if(data.Email != null && data.Password != null) { + var user = new IdentityUser { UserName = data.UserName, Email = data.Email }; + var result = await _manager.CreateAsync(user, data.Password); - if(result.Succeeded) - return Ok(new { Token = GenerateToken(user) }); + if(result.Succeeded) + return Ok(new { Token = GenerateToken(user) }); + } return StatusCode(422, new { error = "The provided user is invalid" }); } |