public ActionResult Index(FormCollection form)
        {
            var account = form["Account"];
            var pasword = form["Password"];
            var code    = form["ValidateCode"];

            if (string.IsNullOrWhiteSpace(account) || string.IsNullOrWhiteSpace(pasword) ||
                string.IsNullOrWhiteSpace(code))
            {
                return(Json(new { success = false, msg = "账户名/密码为空" }, JsonRequestBehavior.AllowGet));
            }
            account = account.Trim();
            pasword = pasword.Trim();
            code    = code.Trim();
            if (!Captcha.CompareAndDestroy(Session, code))
            {
                return(Json(new { success = false, msg = "验证码错误" }, JsonRequestBehavior.AllowGet));
            }
            var tenant = new Tenant()
            {
                Account     = account,
                AccountType = (int)TenantAccountType.Email,
                Password    = pasword,
                Email       = account,
                Owner       = new DBC.WeChat.Models.Infrastructures.Store()
                {
                    Enabled = false
                }
            };
            var svc = ServiceLocator.Resolve <IModelService>("Internal");

            try
            {
                svc.Create(tenant);
                tenant.CreatorID      = null;
                tenant.LastModifiedAt = null;
                tenant.LastModifierID = null;
                RegEmail.Send(tenant, Request);
                Session["Tenant"] = tenant;
            }
            catch (RuleViolatedException ex)
            {
                return(Json(new { success = false, msg = ex.Message }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, msg = "未知错误" }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Index(FormCollection form)
        {
            var account = form["Account"];

            if (string.IsNullOrWhiteSpace(account))
            {
                return(Json(new { success = false, msg = "帐号不存在" }, JsonRequestBehavior.AllowGet));
            }
            var code = form["ValidateCode"];

            if (!Captcha.CompareAndDestroy(Session, code, true, "ForgetImg"))
            {
                return(Json(new { success = false, msg = "验证码错误" }, JsonRequestBehavior.AllowGet));
            }
            account = account.Trim();
            var svc = ServiceLocator.Resolve <IModelService>("Internal");

            //匹配邮箱 匹配手机号
            if (Regex.IsMatch(account, @"^([\w\-]+)(\.[\w]+)*@([\w\-]+\.){1,5}([A-Za-z]){2,4}$") ||
                Regex.IsMatch(account, @"^(13[0-9]|15[012356789]|18[0123456789]|14[57])[0-9]{8}$"))
            {
                var tenant = svc.SelectOrEmpty(new TenantQuery()
                {
                    Account = account
                }).FirstOrDefault();
                if (tenant == null)
                {
                    return(Json(new { success = false, msg = "帐号不存在" }, JsonRequestBehavior.AllowGet));
                }
                if (tenant.AccountType == (int)TenantAccountType.Email && tenant.EmailVerified != true)
                {
                    return(Json(new { success = false, msg = "该邮箱帐号未验证,无法找回" }, JsonRequestBehavior.AllowGet));
                }
                if (tenant.AccountType == (int)TenantAccountType.Mobile && tenant.MobileVerified != true)
                {
                    return(Json(new { success = false, msg = "该手机帐号未验证,无法找回" }, JsonRequestBehavior.AllowGet));
                }
                Session["Account"]   = account;
                Session["Type"]      = tenant.AccountType;
                Session["_TenantID"] = tenant.ID.Value;
            }
            else
            {
                return(Json(new { success = false, msg = "帐号格式错误" }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
        }