Пример #1
0
        public async Task <IActionResult> Phone(PhoneViewModel model)
        {
            var user = await GetCurrentUserAsync();

            if (!ModelState.IsValid)
            {
                model.Recover(user);
                model.ModelStateValid = ModelState.IsValid;
                return(View(model));
            }
            var phone = model.ZoneNumber + model.NewPhoneNumber;
            var code  = await _userManager.GenerateChangePhoneNumberTokenAsync(user, phone);

            await _smsSender.SendAsync(phone, $"Your Aiursoft verification code is: {code}.");

            return(RedirectToAction(nameof(EnterCode), new { newPhoneNumber = phone }));
        }
Пример #2
0
        public async Task <IActionResult> Phone(PhoneViewModel model)
        {
            var user = await GetCurrentUserAsync();

            if (!ModelState.IsValid)
            {
                model.Recover(user);
                model.ModelStateValid = ModelState.IsValid;
                return(View(model));
            }
            if (model.NewPhoneNumber.Length == 11)
            {
                model.NewPhoneNumber = "+86" + model.NewPhoneNumber;
            }
            var code = await _userManager.GenerateChangePhoneNumberTokenAsync(user, model.NewPhoneNumber);

            await _smsSender.SendAsync(model.NewPhoneNumber, "Your security code is: " + code);

            return(RedirectToAction(nameof(EnterCode), new { model.NewPhoneNumber }));
        }