public async Task <ActionResult <ApplicationUser> > Register([FromBody] RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.UserName, Email = model.Email, CountryCode = model.CountryCode, PhoneNumber = model.PhoneNumber, AuthyId = await authy.registerUserAsync(model) }; var result = await this.userManager.CreateAsync(user, model.Password); if (result.Succeeded) { await this.signInManager.SignInAsync(user, authenticationMethod : "AccountSecurityScheme", isPersistent : true); logger.LogInformation(3, "User created a new account with password."); return(user); } else { AddErrors(result); } } return(BadRequest(ModelState)); }