Ejemplo n.º 1
0
 private ActionResult VerifyPhoneNumberView(VerifyPhoneNumberViewModel model)
 {
     return View(ViewNames.VerifyPhoneNumber, model);
 }
Ejemplo n.º 2
0
 public async Task<ActionResult> VerifyPhoneNumber(VerifyPhoneNumberViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var result = await UserManager.ChangePhoneNumberAsync(User.Identity.GetUserId(), model.PhoneNumber, model.Code);
     if (result.Succeeded)
     {
         var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
         if (user != null)
         {
             await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
         }
         return RedirectToAction("Index", new { Message = ManageMessageId.AddPhoneSuccess });
     }
     // If we got this far, something failed, redisplay form
     ModelState.AddModelError("", "Failed to verify phone");
     return View(model);
 }
Ejemplo n.º 3
0
 public async Task<ActionResult> VerifyPhoneNumber(VerifyPhoneNumberViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return VerifyPhoneNumberView(model);
     }
     var result = await UserManager.ChangePhoneNumberAsync(UserId, model.PhoneNumber, model.Code);
     if (!result.Succeeded)
     {
         ModelState.AddModelError("", Properties.Resources.Manage_VerifyPhoneNumber_Failed);
         return VerifyPhoneNumberView(model);
     }
     var user = await UserManager.FindByIdAsync(UserId);
     if (user != null)
     {
         await SignInAsync(user);
     }
     return RedirectToIndex(ManageMessageId.AddPhoneSuccess);
 }
 public async Task<ActionResult> VerifyPhoneNumber(VerifyPhoneNumberViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var result = await UserManager.ChangePhoneNumberAsync(User.Identity.GetUserId(), model.PhoneNumber, model.Code);
     if (result.Succeeded)
     {
         var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
         if (user != null)
         {
             await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
         }
         return RedirectToAction("Index", new { Message = ManageMessageId.AddPhoneSuccess });
     }
     // 如果我们进行到这一步时某个地方出错,则重新显示表单
     ModelState.AddModelError("", "无法验证电话号码");
     return View(model);
 }