public async Task<ActionResult> AddPhoneNumber(AddPhoneNumberViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     // Generate the token and send it
     var code = await UserManager.GenerateChangePhoneNumberTokenAsync(User.Identity.GetUserId<int>(), model.Number);
     if (UserManager.SmsService != null)
     {
         var message = new IdentityMessage
         {
             Destination = model.Number,
             Body = "Your security code is: " + code
         };
         await UserManager.SmsService.SendAsync(message);
     }
     return RedirectToAction("VerifyPhoneNumber", new { PhoneNumber = model.Number });
 }
Esempio n. 2
0
 public async Task<IActionResult> AddPhoneNumber(AddPhoneNumberViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     // Generate the token and send it
     var user = await GetCurrentUserAsync();
     var code = await UserManager.GenerateChangePhoneNumberTokenAsync(user, model.Number);
     await MessageServices.SendSmsAsync(model.Number, "Your security code is: " + code);
     return RedirectToAction("VerifyPhoneNumber", new { PhoneNumber = model.Number });
 }
        public async Task<ActionResult> AddPhoneNumber(AddPhoneNumberViewModel model)
        {
            if (ModelState.IsValid)
            {
                // Send result of: UserManager.GetPhoneNumberCodeAsync(User.Identity.GetUserId(), phoneNumber);
                // Generate the token and send it
                var code = await UserManager.GenerateChangePhoneNumberTokenAsync(User.Identity.GetUserId(), model.Number);
                if (UserManager.SmsService != null)
                {
                    var message = new IdentityMessage
                    {
                        Destination = model.Number,
                        Body = "Your security code is: " + code
                    };
                    await UserManager.SmsService.SendAsync(message);
                }

                return RedirectToAction("VerifyPhoneNumber", new { PhoneNumber = model.Number });
            }
            // If we got this far, something failed, redisplay form
            return View(model);
        }
Esempio n. 4
0
 public async Task<ActionResult> AddPhoneNumber(AddPhoneNumberViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     // Gerar um token e enviar
     var code = await UserManager.GenerateChangePhoneNumberTokenAsync(User.Identity.GetUserId(), model.Number);
     if (UserManager.SmsService != null)
     {
         var message = new IdentityMessage
         {
             Destination = model.Number,
             Body = "O código de segurança é: " + code
         };
         await UserManager.SmsService.SendAsync(message);
     }
     return RedirectToAction("VerifyPhoneNumber", new { PhoneNumber = model.Number });
 }