示例#1
0
        public async Task <IActionResult> OnGet(string returnTo, bool rememberMe)
        {
            var user = await _signInManager.GetTwoFactorAuthenticationUserAsync();

            if (user == null)
            {
                return(RedirectToPage("/Error"));
            }

            var providers = await _userManager.GetValidTwoFactorProvidersAsync(user);


            var providerList = providers.Select(provider => new SelectListItem {
                Value = provider, Text = provider
            })
                               .ToList();

            SendCode = new SendCode()
            {
                Providers  = providerList,
                RememberMe = rememberMe,
                ReturnTo   = returnTo
            };

            return(Page());
        }
示例#2
0
        public void SendCodeView_Template_Test()
        {
            var template = new SendCode(new SmartAppInfo {
                Id = ApplicationId
            });
            var output = template.TransformText();

            Assert.NotNull(output);
            Assert.NotEmpty(output);
            Assert.Contains($"@model {ApplicationId}.Backend.Models.SendCodeViewModel", output);
        }
示例#3
0
        public async Task <IHttpActionResult> SendCode(SendCode model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // Generate the token and send it
            if (!await _AppSignInManager.SendTwoFactorCodeAsync(model.SelectedProvider))
            {
                return(BadRequest("Error"));
            }
            return(Ok(new { Provider = model.SelectedProvider, ReturnUrl = model.ReturnUrl, RememberMe = model.RememberMe }));
        }
示例#4
0
文件: UserApp.cs 项目: HOMEFW/FWS
        public async Task <ActionResult> SendCode(SendCode model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            // Generate the token and send it
            if (!await SignInManager.SendTwoFactorCodeAsync(model.SelectedProvider))
            {
                return(View("Error"));
            }
            return(RedirectToAction("VerifyCode", new { Provider = model.SelectedProvider, ReturnUrl = model.ReturnUrl, RememberMe = model.RememberMe }));
        }
示例#5
0
        public async Task <IActionResult> SendCode(SendCode model, string returnTo)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }


            var user = await _signInManager.GetTwoFactorAuthenticationUserAsync();


            if (user == null)
            {
                return(View("Error"));
            }

            var code = await _userManager.GenerateTwoFactorTokenAsync(user, model.SelectedProvider);

            if (string.IsNullOrEmpty(code))
            {
                return(View("Error"));
            }

            var message = $"Confirm Code: {code}";

            if (model.SelectedProvider == "Email")
            {
                await _emailSender.SendEmailAsync(user.Email, "Confirm Code", message);
            }
            else if (model.SelectedProvider == "Phone")
            {
                await _smsSender.SendSmsAsync(user.PhoneNumber, message);
            }


            return(RedirectToRoute("GetVerifyCode",
                                   new
            {
                returnTo,
                rememberMe = model.RememberMe,
                provider = model.SelectedProvider
            }));
        }
    public void OnbtlClick()
    {
        CleanMessage();
        buttonSend.enabled = false;

        string mobile = inputMobile.value.Trim();

        if (mobile == null || "".Equals(mobile))
        {
            ShowMessage(ErrorCode.EC_UC_NO_MOBILE);
            buttonSend.enabled = true;
            return;
        }

        if (!RegexHelper.isMobile(mobile))
        {
            ShowMessage(ErrorCode.EC_UC_INVALID_MOBILE);
            buttonSend.enabled = true;
            return;
        }

        string s = resend ? "1" : "0";
//            SendLoginVerificationCodeReq req = new SendLoginVerificationCodeReq
//            {
//                DeviceType = DeviceHelper.getDeviceType(),
//                FingerPrint = SystemInfo.deviceUniqueIdentifier,
//                Mobile = mobile,
//                Resend = s,
//                LastChannel = lastChannel
//            };

        SendCode sc = new SendCode()
        {
            deviceType  = DeviceHelper.getDeviceType(),
            fingerPrint = SystemInfo.deviceUniqueIdentifier,
            mobile      = mobile,
            resend      = s,
            lastChannel = lastChannel
        };

        HttpPost(Constants.API_ID_SEND_CODE, ProtoHelper.Proto2Bytes(sc));
    }
示例#7
0
        public async Task <IActionResult> SendCode(SendCode model)
        {
            if (!_accessor.ActionContext.ModelState.IsValid)
            {
                return(new OkResult());
            }

            var user = await _signInManager.GetTwoFactorAuthenticationUserAsync();

            if (user == null)
            {
                return(new OkObjectResult("Error"));
            }

            if (model.SelectedProvider == "Authenticator")
            {
                return(new RedirectToActionResult(nameof(VerifyAuthenticatorCode), new { ReturnUrl = model.ReturnUrl, RememberMe = model.RememberMe }));
            }

            // Generate the token and send it
            var code = await _userManager.GenerateTwoFactorTokenAsync(user, model.SelectedProvider);

            if (string.IsNullOrWhiteSpace(code))
            {
                return(new OkObjectResult("Error"));
            }

            var message = "Your security code is: " + code;

            if (model.SelectedProvider == "Email")
            {
                await _emailSender.SendEmailAsync(await _userManager.GetEmailAsync(user), "Security Code", message);
            }
            else if (model.SelectedProvider == "Phone")
            {
                await _smsSender.SendSmsAsync(await _userManager.GetPhoneNumberAsync(user), message);
            }

            return(new RedirectToActionResult(nameof(VerifyCode), new { Provider = model.SelectedProvider, ReturnUrl = model.ReturnUrl, RememberMe = model.RememberMe }));
        }
示例#8
0
        void OnProcessData(OperationRequest oper)
        {
            //Console.WriteLine("OnProcessData="+oper.OperationCode +" " +oper.Parameters);

            switch (oper.OperationCode)
            {
            case SendCode.SEND_FILE_END:
                if (isGetFile && file != null)
                {
                    file.Close();
                    isGetFile = false;
                    file      = null;
                    if (SendCode.Equals(oper.Parameters, SendCode.SUCCEED))
                    {
                        Console.WriteLine("文件保存成功!!");
                    }
                    else
                    {
                        Console.WriteLine("文件保存失败!!");
                    }
                }
                break;

            case SendCode.SEND_FILE_DATA:
                if (isGetFile && file != null)
                {
                    file.Write(oper.operationData, 0, oper.operationData.Length);
                }
                break;

            case SendCode.SEND_FILE_HEAD:
                string[] mess     = oper.Parameters.Split('|');
                string   fileName = mess[0];

                //Console.WriteLine("开始接收文件 [Name," + fileName+"][Size,"+ mess[1]+"]");
                file      = File.Create(AppDomain.CurrentDomain.RelativeSearchPath + fileName);
                isGetFile = true;
                break;

            case 104:
                string[] mss = oper.Parameters.Split('|');

                Console.WriteLine("房间消息[" + mss[0] + "," + mss[1] + "]");
                break;

            case 10100:
                Console.WriteLine(SendCode.Equals(oper.Parameters, SendCode.SUCCEED) ?"房间创建成功":"房间创建失败");
                break;

            case 10200:
                Console.WriteLine(SendCode.Equals(oper.Parameters, SendCode.SUCCEED) ? "房间加入成功" : "房间加入失败");
                break;

            case 10500:
                Console.WriteLine("房间信息:" + oper.Parameters);
                break;

            default:
                break;
            }
        }
示例#9
0
        public void SendCodeView_Template_NullParameter_Test()
        {
            var template = new SendCode(null);

            Assert.Throws <NullReferenceException>(() => template.TransformText());
        }
示例#10
0
        private void TransformViewsAccountSendCode(SmartAppInfo manifest)
        {
            var template = new SendCode(manifest);

            _writingService.WriteFile(Path.Combine(_context.BasePath, template.OutputPath), template.TransformText());
        }
示例#11
0
 public NikePage clickSendButton()
 {
     SendCode.Click();
     return(this);
 }