Example #1
0
        public ActionResult GetPassword(FormCollection fc)
        {
            var    flag    = false;
            var    message = "";
            string Phone   = fc["Phone"];
            var    q       = QueryBuilder.Create <Data.Users>().Equals(x => x.Phone, Phone);
            var    model   = Data.UsersDB.GETUsers(q);

            if (model == null)
            {
                flag    = false;
                message = "不存在的电话号码.";
            }
            else
            {
                string Code = SMS.CreateCode();
                flag = UsersDB.ChangePWD(model.ID, Encrypt.DES.Des_Encrypt(Code));
                if (flag)
                {
                    SMS.Send(Phone, Code);
                    var smsModel = new Data.SMSCode();
                    smsModel.Code       = Code;
                    smsModel.CreateTime = DateTime.Now;
                    smsModel.EndTime    = smsModel.CreateTime.AddMinutes(10);
                    smsModel.IsUse      = false;
                    smsModel.Phone      = Phone;
                    Data.SMSCodeDB.AddSMSCode(smsModel);
                }
                message = "新密码已发送到您号码为" + Phone + "的手机上.";
            }
            return(Json(new { success = flag, message = message }, JsonRequestBehavior.AllowGet));
        }