Skip to content

Instantly share code, notes, and snippets.

@babaktaremi
Created August 22, 2021 10:10
Show Gist options
  • Save babaktaremi/963b1de8a3e1361d132169092094faa0 to your computer and use it in GitHub Desktop.
Save babaktaremi/963b1de8a3e1361d132169092094faa0 to your computer and use it in GitHub Desktop.
[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