Пример #1
0
        public ActionResult CheckAccount(string phone, AccountVerifyTypeEnum type)
        {
            bool result = accountBll.CheckPhone(phone, type);
            var  msg    = result ? "校验成功" : "校验失败";

            return(SimpleResult(result));
        }
Пример #2
0
        public ActionResult SendValidCode(string phone, AccountVerifyTypeEnum type, string authCode = "")
        {
            bool checkAuthCode = true;
            bool checkPhone    = false;

            if (string.IsNullOrEmpty(phone))
            {
                return(new JsonResult()
                {
                    Data = AjaxResponse.Fail(SmsErrorEnum.PhoneInvalid)
                });
            }
            if (type == AccountVerifyTypeEnum.校区找回密码)
            {
                checkAuthCode = VerifyCode.Check(authCode);
                if (!checkAuthCode)
                {
                    return(new JsonResult()
                    {
                        Data = AjaxResponse.Fail(SmsErrorEnum.AuthCodeError)
                    });
                }
            }
            if (checkAuthCode)
            {
                checkPhone = accountBll.CheckPhone(phone, type);
            }
            if (!checkPhone)
            {
                SmsErrorEnum errorCode = SmsErrorEnum.PhoneInvalid;
                switch (type)
                {
                case AccountVerifyTypeEnum.学生未注册:
                case AccountVerifyTypeEnum.校区教师未注册:
                case AccountVerifyTypeEnum.教研教师未注册:
                    errorCode = SmsErrorEnum.PhoneRegistered;
                    break;

                case AccountVerifyTypeEnum.学生已注册:
                case AccountVerifyTypeEnum.校区教师已注册:
                case AccountVerifyTypeEnum.校区找回密码:
                case AccountVerifyTypeEnum.教研教师已注册:
                    errorCode = SmsErrorEnum.PhoneNoRegister;
                    break;

                default:
                    break;
                }
                return(new JsonResult()
                {
                    Data = AjaxResponse.Fail(errorCode)
                });
            }
            if (type != AccountVerifyTypeEnum.校区找回密码)
            {
                LogonUserAccessCheckPolicy checkPolicy = new LogonUserAccessCheckPolicy(
                    AccessCheckKeyEnum.Chinese_SchoolSMSCode_Check,
                    CurrentUser.Teacher.Yoh_Id.ToString(),
                    50,
                    1,
                    0);
                if (!checkPolicy.Check())
                {
                    return(new JsonResult()
                    {
                        Data = AjaxResponse.Fail(SmsErrorEnum.SendSmsTooOften)
                    });
                }
            }


            //enumSMSCheckResult result = SMSAccessSecurityManager.Check(clsCommon.GetIP());

            //if (result == enumSMSCheckResult.UserLimited || result == enumSMSCheckResult.GlobalLimited)
            //{
            //    return new JsonResult() { Data = AjaxResponse.Fail(SmsErrorEnum.SendSmsTooOften) };
            //}

            int code = new Random().Next(1001, 9999);

            //return new JsonResult() { Data = AjaxResponse.Success() };//status:1
            try
            {
                if (SendSms(phone, code.ToString(), type))
                {
                    SmsCookie.SetSmsCode(phone, code);
                    return(new JsonResult()
                    {
                        Data = AjaxResponse.Success()
                    });                                                       //status:1
                }
                else
                {
                    return(new JsonResult()
                    {
                        Data = AjaxResponse.Fail(SmsErrorEnum.SystemError)
                    });
                }
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLog("发短信error", ex);
                return(new JsonResult()
                {
                    Data = AjaxResponse.Fail(SmsErrorEnum.SystemError)
                });
            }
        }