public async Task <IActionResult> Register([FromBody] RegisterViewModel model) { //if (!ModelState.IsValid) //{ // var errrors = CustomValidator.GetErrorsByModel(ModelState); // return BadRequest(errrors); //} var user = new DbUser { UserName = model.Email, Email = model.Email }; var result = await _userManager.CreateAsync(user, model.Password); if (!result.Succeeded) { return(BadRequest(result.Errors)); } await _signInManager.SignInAsync(user, isPersistent : false); EmailSend emailSend = new EmailSend(); await emailSend.SendEmailAsync(model.Email, "Confirm your account", "Confirm your account"); return(Ok( new { token = CreateTokenJwt(user) })); }