public async Task <IActionResult> Register([FromBody] CreateUserParams userParams) { var user = new UserDto { FirstName = userParams.FirstName, LastName = userParams.LastName, Email = userParams.Email, Username = userParams.Username, }; var resultingUser = await _userEngine.CreateUser(user, userParams.Password); if (resultingUser != null) { var code = await _userEngine.GenerateEmailConfirmation(resultingUser); var link = $"{Request.Scheme}://{Request.Host}/api/auth/confirmEmail?userId={resultingUser.Id}&code={HtmlEncoder.Default.Encode(code)}"; var text = $"Confirm your account here: {link} "; await _emailEngine.SendEmail(new EmailDto { ToAddresses = new List <string> { userParams.Email }, Subject = "Verify Your Account", TextContent = text }); return(Ok()); } return(Unauthorized()); }