Exemplo n.º 1
0
        public ActionResult SendLoginValidSMS(FormCollection form)
        {
            //step one :get customer cellphone from db
            string customerID = form["CustomerID"];

            if (string.IsNullOrEmpty(customerID))
            {
                return(Json("用户名未提供,发送验证码失败。", JsonRequestBehavior.AllowGet));
            }

            string vendorUserCellphone = CommonService.GetVendorCellPhone(customerID);

            //step two :send sms
            if (string.IsNullOrEmpty(vendorUserCellphone))
            {
                return(Json("账户未绑定手机或是未完成验证绑定,获取验证码失败。", JsonRequestBehavior.AllowGet));
            }
            else
            {
                string code = ValidationCodeHelper.CreateValidateCode(5);
                Session["ValidateCode"] = code;
                CookieHelper.SaveCookie <string>("VerifyCode", code.Trim());
                string SMSContent = string.Format(AppSettingManager.GetSetting("SMSTemplate", "CreateConfirmPhoneCode"),
                                                  DateTime.Now.ToString("MM月dd日 HH:mm"), code);
                if (SMSService.SendSMS(vendorUserCellphone, SMSContent))
                {
                    return(Json("s", JsonRequestBehavior.AllowGet));
                }
            }
            return(Json("服务器忙,稍后重试", JsonRequestBehavior.AllowGet));
        }
        public ActionResult LoginValidationCode()
        {
            string code = ValidationCodeHelper.CreateValidateCode(5);

            byte[] bytes = ValidationCodeHelper.CreateValidateGraphic(code, 52);
            CookieHelper.SaveCookie <string>(AuthMgr.LOGIN_VERIFYCODE_COOKIE, code.Trim());
            return(File(bytes, @"image/jpeg"));
        }
Exemplo n.º 3
0
        public ActionResult LoginValidationCode()
        {
            string code = ValidationCodeHelper.CreateValidateCode(5);

            Session["ValidateCode"] = code;
            byte[] bytes = ValidationCodeHelper.CreateValidateGraphic(code, 34);
            CookieHelper.SaveCookie <string>("VerifyCode", code.Trim());
            return(File(bytes, @"image/jpeg"));
        }
Exemplo n.º 4
0
        private void btnSMS_Click(object sender, RoutedEventArgs e)
        {
            string account = TextBoxLoginName.Text;

            if (string.IsNullOrEmpty(account))
            {
                this.TextBlockLoginFaild.Visibility = System.Windows.Visibility.Visible;
                TextBlockLoginFaild.Text            = "用户名未提供,发送验证码失败。";
                return;
            }

            string     serviceUrl = CPApplication.Current.CommonData["ECCentralServiceURL_Login"].ToString();
            string     userUrl    = string.Format("{0}/CommonService/ControlPanelUser/LoginUser", serviceUrl);
            RestClient c_Client   = new RestClient(serviceUrl);

            c_Client.Query <ControlPanelUser>(userUrl, account, (target, args) =>
            {
                if (args == null || args.Result == null)
                {
                    this.TextBlockLoginFaild.Visibility = Visibility.Visible;
                    TextBlockLoginFaild.Text            = "账户未绑定手机或是未完成验证绑定,获取验证码失败。";
                    return;
                }
                //step two :send sms
                if (string.IsNullOrEmpty(args.Result.PhoneNumber))
                {
                    this.TextBlockLoginFaild.Visibility = Visibility.Visible;
                    TextBlockLoginFaild.Text            = "账户未绑定手机或是未完成验证绑定,获取验证码失败。";
                    return;
                }
                else
                {
                    string code       = ValidationCodeHelper.CreateValidateCode(5);
                    string SMSContent = string.Format("您于{0}在泰隆优选申请验证手机。动态验证码:{1}",
                                                      DateTime.Now.ToString("MM月dd日 HH:mm"), code);
                    string smsurl       = string.Format("{0}/CommonService/Message/SendSMS", serviceUrl);
                    RestClient m_Client = new RestClient(serviceUrl);

                    SMSInfo smsc = new SMSInfo()
                    {
                        CellPhoneNum = args.Result.PhoneNumber,
                        Content      = SMSContent,
                        Priority     = 3
                    };
                    m_Client.Query <List <Question> >(smsurl, smsc, (target1, args1) =>
                    {
                        UtilityHelper.SetIsolatedStorage("smsDate", DateTime.Now.ToString());
                        UtilityHelper.SetIsolatedStorage("smsCode", code);
                    });
                }
            });
        }
Exemplo n.º 5
0
        public ActionResult LoginValidationCode()
        {
            string code = ValidationCodeHelper.CreateValidateCode(5);

            byte[] bytes   = ValidationCodeHelper.CreateValidateGraphic(code, 34);
            var    options = new CookieOptions()
            {
                Domain   = AppSettings.EnvironmentVariable == "pre" ? "MessageCenter.Pre" : "MessageCenter",
                HttpOnly = true
            };

            //验证码应该做加密处理,不然形同虚设
            HttpContext.Response.Cookies.Append("LoginVerifyCode", HashEncrypt.DESEncrypt(code.Trim(), "hpmcgctr"));
            return(File(bytes, @"image/jpeg"));
        }