Created
August 22, 2021 10:10
-
-
Save babaktaremi/963b1de8a3e1361d132169092094faa0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost("Register")] | |
public async Task<IActionResult> Register(RegisterViewModel model) | |
{ | |
var user = new User {UserName = model.UserName}; | |
var result = await _userManager.CreateAsync(user,model.Password); | |
if (result.Succeeded) | |
{ | |
var token = await _jwtService.GenerateAsync(user); | |
return Ok(token); | |
} | |
var errors = string.Join("|", result.Errors.Select(c => c.Description)); | |
return BadRequest(errors); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment