public async Task <IActionResult> ConfirmPhone(string username, string phonenumber, string code) { var pars = new[] { username, phonenumber, code }; if (pars.Any(string.IsNullOrWhiteSpace)) { return (Res.PlainUtf8( "One or more of required fields username, phonenumber and code were missing or empty.", 400)); } var user = await _userManager.FindByNameAsync(username); var valid = await _userManager.VerifyChangePhoneNumberTokenAsync(user, code, phonenumber); if (!valid) { return(Res.PlainUtf8("Invalid Code", 400)); } user.PhoneNumber = phonenumber; user.PhoneNumberConfirmed = true; var res = await _userManager.UpdateAsync(user); return(res.Succeeded ? Res.PlainUtf8("Success, phone number confirmed.") : Res.PlainUtf8(res.PrettyErrors(), 500)); }