コード例 #1
0
ファイル: ValicodeController.cs プロジェクト: gowhy/MicroWish
        public ActionResult Phone(string phone)
        {
            var pattern =new Regex( @"^1[3-9][0-9]\d{8}$");
            if (!phone.Match(pattern)) return Error("请输入正确的手机号码");

            var isHas = DbProvider.D<User>().Any(x => x.Mobile == phone && x.MobilePassed);
            if (isHas) return Error("手机号已经存在,请重新输入!");

            var vCode = new ValidateImage();
            var code = vCode.CreateValidateCode(4);
            var valicode = new HttpCookie("valicode") { Value = code.Hash().Hash(),Expires = DateTime.Now.AddMinutes(30)};
            var mobile = new HttpCookie("mobile") { Value = phone.Hash().Hash(),Expires = DateTime.Now.AddMinutes(30)};

            //线下和路人不发短信

            var msg = new MsgQueueFactory().CreateValidatorMsg(phone,code);
            DbProvider.Add(msg);
            DbProvider.SaveChanges();

            QuickSendSMS(msg);

            Response.AppendCookie(valicode);
            Response.AppendCookie(mobile);
            return Success("发送成功");
        }
コード例 #2
0
ファイル: ValicodeController.cs プロジェクト: gowhy/MicroWish
        public ActionResult FindPasswordByPhone(string phone)
        {
            var pattern = new Regex(@"^1[3-9][0-9]\d{8}$");
            if (!phone.Match(pattern)) return Error("请输入正确的手机号码");

            var qdt_account = Request.Cookies["qdt_account"];
            if (qdt_account == null) return Error("此页面已经过期");

            var Pid = Convert.ToInt32(qdt_account.Value.ToDesDecrypt(Des.LoveBank_Key));

            var user = DbProvider.GetByID<User>(Pid);
            if (!user.MobilePassed || phone != user.Mobile)
            {
                return Error("手机号与绑定手机号不匹配!");
            }

            var vCode = new ValidateImage();
            var code = vCode.CreateValidateCode(4);
            var valicode = new HttpCookie("valicode") { Value = code.Hash().Hash() };
            var mobile = new HttpCookie("mobile") { Value = phone.Hash().Hash() };

            //线下和路人不发短信

            var msg = new MsgQueueFactory().CreateValidatorMsg(phone, code);
            DbProvider.Add(msg);
            DbProvider.SaveChanges();

            QuickSendSMS(msg);

            Response.AppendCookie(valicode);
            Response.AppendCookie(mobile);

            return Success("发送成功");
        }
コード例 #3
0
ファイル: AccountController.cs プロジェクト: gowhy/MicroWish
        public ActionResult Email(string Email)
        {
            var isHas = DbProvider.D<User>().Any(x => x.Email == Email && x.EmailPassed);
            if (isHas) return Error("邮箱已经存在,请重新输入!");

            var qdt_account = Request.Cookies["qdt_account"];
            if (qdt_account == null) return Error("验证超时!请重新登录获取验证");

            var Pid = Convert.ToInt32(qdt_account.Value.ToDesDecrypt(Des.LoveBank_Key));
            var Ptime = DateTime.Now.Ticks;
            var Psign = Email + Des.LoveBank_Key + Ptime.ToString();
            var activateUrl = MakeActiveUrl(Url.Action("PostRegisterBindEmail", "Account", new { id = Pid, email = Email, time = Ptime, sign = Psign.Hash().Hash() }));
            var content = PrepareMailBodyWith("Registration", "Email", Email, "ActiveUrl", activateUrl);
            var msg = new MsgQueueFactory().CreateValidatorMsg(Email, "邮箱验证", content);

            DbProvider.Add(msg);
            DbProvider.SaveChanges();

            SendMailMessage(msg);

            return RedirectToAction("EmailRegSuccess", new { id=Pid,email = Email });
        }
コード例 #4
0
ファイル: AccountController.cs プロジェクト: gowhy/MicroWish
        public ActionResult SendPasswordByEmail(string email)
        {
            if (!email.IsEmail()) return Error("请输入正确的电子邮件");

            var qdt_account = Request.Cookies["qdt_account"];
            if (qdt_account == null) return Error("此页面已经过期");

            var Pid = Convert.ToInt32(qdt_account.Value.ToDesDecrypt(Des.LoveBank_Key));

            var user = DbProvider.GetByID<User>(Pid);
            if (!user.EmailPassed || email != user.Email)
            {
                return Error("电子邮件与绑定邮箱地址不匹配!");
            }

            var Ptime = DateTime.Now.Ticks;
            var Psign = email + Des.LoveBank_Key + Ptime.ToString();
            var resetUrl = MakeActiveUrl(Url.Action("ResetPasswordByEmail", "Account", new { email = email, time = Ptime, sign = Psign.Hash().Hash() }));
            var content = PrepareMailBodyWith("ForgetPwd", "Email", email, "ResetUrl", resetUrl);
            var msg = new MsgQueueFactory().CreateValidatorMsg(email, "找回密码", content);
            msg.IsSend = true;

            DbProvider.Add(msg);
            DbProvider.SaveChanges();

            SendMailMessage(msg);

            return View("EmailFindpasswordSuccess", user);
        }
コード例 #5
0
ファイル: SafeController.cs プロジェクト: gowhy/MicroWish
        public ActionResult SendSafeByPhone()
        {
            if (!User.MobilePassed || string.IsNullOrWhiteSpace(User.Mobile))
            {
                return Error("手机号与绑定手机号不匹配!");
            }

            var vCode = new ValidateImage();
            var code = vCode.CreateValidateCode(4);
            var valicode = new HttpCookie("valicode") { Value = code.Hash().Hash() };
            var mobile = new HttpCookie("mobile") { Value = User.Mobile.Hash().Hash() };

            //线下和路人不发短信

            var msg = new MsgQueueFactory().CreateValidatorMsg(User.Mobile, code);
            DbProvider.Add(msg);
            DbProvider.SaveChanges();

            QuickSendSMS(msg);

            Response.AppendCookie(valicode);
            Response.AppendCookie(mobile);
            return Success("发送成功");
        }