Esempio n. 1
0
        public async Task <ActionResult> AddPhoneNumber(AddPhoneNumberViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            // 生成令牌并发送该令牌
            var code = await UserManager.GenerateChangePhoneNumberTokenAsync(User.Identity.GetUserId(), model.Number);

            if (UserManager.SmsService != null)
            {
                var message = new IdentityMessage
                {
                    Destination = model.Number,
                    Body        = "你的安全代码是: " + code
                };
                await UserManager.SmsService.SendAsync(message);
            }
            return(RedirectToAction("VerifyPhoneNumber", new { PhoneNumber = model.Number }));
        }