示例#1
0
        public JsonResult EmailNotifyForChangePwd(string email)
        {
            if (string.IsNullOrEmpty(email))
            {
                return(Json(new { code = OperationResultType.Error, message = Msg_ChangPwd_Notify + "失败,邮箱不能为空" }));
            }
            var verifyCode = VerificationCodeHelper.Create(VerifyCodeLength, false);

            if (!verifyCode.Check())
            {
                return(Json(new { code = OperationResultType.Error, message = Msg_ChangPwd_Notify + "失败,生成验证码时错误" }));
            }
            //验证码以及生成时间写入session
            Session.Set(KEY_Session_VerifyCode_ChangePwd, verifyCode.Code);
            Session.Set(KEY_Session_VerifyCode_ChangePwd_BeginTime, DateTime.Now);

            //调用验证码通知器
            VerifyCodeEmailNotifyer notifier = new VerifyCodeEmailNotifyer();

            notifier.Notify(verifyCode.Code, email);

            return(Json(new
            {
                code = OperationResultType.Success,
                message = string.Format("验证码已发送到您的邮箱,有效期{0}分钟,请及时查收。", VerifyCodeExpireTime)
            }));
        }
示例#2
0
        public ActionResult GetVerifycationCode()
        {
            var verifyCode = VerificationCodeHelper.Create(VerifyCodeLength);

            if (!verifyCode.Check())
            {
                return(null);
            }
            Session.Set(KEY_Session_VerifyCode_Login, verifyCode.Code);
            return(File(verifyCode.ImageBytes, @"image/jpeg"));
        }