Пример #1
0
 public async Task<IActionResult> VerifyPhoneNumber(VerifyPhoneNumberViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var user = GetCurrentUser();
     if (user != null)
     {
         var result = await _userManager.ChangePhoneNumberAsync(user, model.PhoneNumber, model.Code);
         if (result.Succeeded)
         {
             await _signInManager.SignInAsync(user, isPersistent: false);
             return RedirectToAction(nameof(Index), new { Message = ManageMessageId.AddPhoneSuccess });
         }
     }
     // If we got this far, something failed, redisplay the form
     ModelState.AddModelError(string.Empty, "Failed to verify phone number");
     return View(model);
 }
Пример #2
0
        public async Task<IActionResult> VerifyPhoneNumber(VerifyPhoneNumberViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            var user = GetCurrentUser();
            if (user != null)
            {
                var result = await _userManager.ChangePhoneNumberAsync(user, model.PhoneNumber, model.Code);
                if (result.Succeeded)
                {
                    await UpdateUserProfileCompleteness(user);
                    await _signInManager.SignInAsync(user, isPersistent: false);                    
                    return RedirectToAction(nameof(Microsoft.Data.Entity.Metadata.Internal.Index), new { Message = ManageMessageId.AddPhoneSuccess });
                }
            }

            // If we got this far, something failed, redisplay the form
            ModelState.AddModelError(string.Empty, FAILED_TO_VERIFY_PHONE_NUMBER);
            return View(model);
        }