/// <summary> /// 发送解绑手机验证码 /// <para>@mobile:手机号</para> /// <para>@rv:验证码</para> /// </summary> private ActionResult SendUnBindingCode(NxpDictionary<string, object> nxpDictionary) { var mobile = nxpDictionary.GetString("mobile", string.Empty); var userid = nxpDictionary.GetInt32("userid", 0); var member = _memberService.GetById(userid); if (member.Mobile != mobile) { return LogError("请输入正确的手机号"); } if (string.IsNullOrWhiteSpace(member.Mobile)) { return LogError("手机号已解除绑定"); } var code = new Random().Next(1000, 9999); var res = _memberService.SendSmsUnbindingMobileMessage(mobile, code.To<string>()); if (!res) { return LogError("发送失败或使用次数已满"); } //验证码写入Session Session["UNBINDING_CODE_" + WebHelper.Md5(mobile)] = code; Session["UNBINDING_CODE_COUNT_" + WebHelper.Md5(mobile)] = 0; return ShowResult("验证码已发送"); }
/// <summary> /// 发送找回密码验证码 /// <para>@username:用户名</para> /// <para>@rv:验证码</para> /// </summary> private ActionResult SendFindPasswordCode(NxpDictionary<string, object> nxpDictionary) { var userName = nxpDictionary.GetString("username", string.Empty); var rv = nxpDictionary.GetString("rv", string.Empty); if (string.IsNullOrEmpty(rv) || rv != Session["VALIDATE_CODE"].To<string>(string.Empty)) { return LogError("输入的答案不正确"); } var member = _memberService.GetByName(userName); if (member == null) { return LogError("用户名不存在"); } if (member.IsBindingMobile != 1) { return LogError("用户未绑定手机号"); } if (member.Status != 0) { return LogError("用户账号被冻结"); } var code = new Random().Next(1000, 9999); var res = _memberService.SendSmsRegisterMessage(member.Mobile, code.To<string>()); if (!res) { return LogError("发送失败或使用次数已满"); } //验证码写入Session Session["FINDPASSWORD_CODE_" + WebHelper.Md5(userName)] = code; Session["FINDPASSWORD_CODE_COUNT_" + WebHelper.Md5(userName)] = 0; return ShowResult("验证码已发送"); }
/// <summary> /// 发送注册验证码 /// <para>@mobile:手机</para> /// <para>@rv:验证码</para> /// </summary> private ActionResult SendRegisterCode(NxpDictionary<string, object> nxpDictionary) { var mobile = nxpDictionary.GetString("mobile", string.Empty);; var rv = nxpDictionary.GetString("rv", string.Empty); if (string.IsNullOrEmpty(rv) || rv != Session["VALIDATE_CODE"].To<string>(string.Empty)) { return LogError("输入的答案不正确"); } if (!Regex.IsMatch(mobile, "\\d{11}")) { return LogError("非法手机号"); } var member = _memberService.GetByName(mobile); if (member != null && member.Id > 0) { return LogError("手机号已存在"); } var tempMember = _memberService.GetByMobile(mobile); if (tempMember != null && tempMember.Id > 0) { return LogError("该手机号已被其他账号绑定"); } var code = new Random().Next(1000, 9999); var res = _memberService.SendSmsRegisterMessage(mobile, code.To<string>()); if (!res) { return LogError("发送失败或使用次数已满"); } //验证码写入Session Session["REGISTER_CODE_" + WebHelper.Md5(mobile)] = code; Session["REGISTER_CODE_COUNT_" + WebHelper.Md5(mobile)] = 0; return ShowResult("成功发送了验证码"); }
/// <summary> /// 发送绑定手机验证码 /// <para>@mobile:手机号</para> /// <para>@rv:验证码</para> /// </summary> private ActionResult SendBindingCode(NxpDictionary<string, object> nxpDictionary) { var mobile = nxpDictionary.GetString("mobile", string.Empty); var rv = nxpDictionary.GetString("rv", string.Empty); if (string.IsNullOrEmpty(rv) || rv != Session["VALIDATE_CODE"].To<string>(string.Empty)) { return LogError("输入的答案不正确"); } if (!Regex.IsMatch(mobile, "\\d{11}")) { return LogError("非法手机号"); } if (_memberService.GetByMobile(mobile) != null) { return LogError("手机号已被绑定"); } var code = new Random().Next(1000, 9999); var res = _memberService.SendSmsBindingMobileMessage(mobile, code.To<string>()); if (!res) { return LogError("发送失败或使用次数已满"); } //验证码写入Session Session["BINDING_CODE_" + WebHelper.Md5(mobile)] = code; Session["BINDING_CODE_COUNT_" + WebHelper.Md5(mobile)] = 0; return ShowResult("验证码已发送"); }