예제 #1
0
        /// <summary>
        /// 找回密码发送验证码
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        public JsonBackResult FindUserInfo(string email)
        {
            if (!RegularHelper.IsEmail(email))
            {
                return(JsonBackResult(ResultStatus.EmailErr));
            }
            var user = this._userWebService.GetList(s => s.EMail == email).ToList().FirstOrDefault();

            if (user == null)
            {
                return(JsonBackResult(ResultStatus.EmailNoExist, user));
            }
            Tuple <string, bool> items = EmailSend.SendEmail(email, "SongBiKe网络博客", "用户找回密码验证码");
            string code = items.Item1;

            Session.Add("ReVerifyCode", code);
            bool sendRes = items.Item2;

            if (sendRes)
            {
                bool res1 = CacheHelper.Set("PwdBackCode", code, DateTime.Now.AddSeconds(90));
                bool res2 = CacheHelper.Set("PwdBackEMail", email, DateTime.Now.AddSeconds(90));//判断用户发送验证码和注册用的是同一个邮箱
                if (res1 && res2)
                {
                    return(JsonBackResult(ResultStatus.Success));
                }
            }
            return(JsonBackResult(ResultStatus.Fail));
        }
예제 #2
0
        /// <summary>
        /// 获取验证码
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        public JsonBackResult GetCode(string email)
        {
            if (!RegularHelper.IsEmail(email))
            {
                return(JsonBackResult(ResultStatus.EmailErr));
            }
            var user = this._userWebService.GetList(t => t.EMail == email && t.State == 1).FirstOrDefault();

            if (user != null)
            {
                return(JsonBackResult(ResultStatus.EmailExist));
            }
            Tuple <string, bool> items = EmailSend.SendEmail(email, "Songbike网络博客", "用户注册码");
            string code = items.Item1;

            Session.Add("VerifyCode", code);
            bool sendRes = items.Item2;

            if (sendRes)
            {
                bool res1 = CacheHelper.Set("RegCode", code, DateTime.Now.AddSeconds(90));
                bool res2 = CacheHelper.Set("Email", email, DateTime.Now.AddSeconds(90));
                if (res1 && res2)
                {
                    return(JsonBackResult(ResultStatus.Success));
                }
            }
            return(JsonBackResult(ResultStatus.Fail));
        }
예제 #3
0
        public JsonNetResult ValidatePwdBackCode(string code, string eMail)
        {
            if (!RegularHelper.IsEmail(eMail))//判断邮箱格式是否正确
            {
                return(JsonNetResult(ResultStatus.EmailErr));
            }
            if (CacheHelper.Get("PwdBackEMail") == null || (CacheHelper.Get("PwdBackEMail").ToString() != eMail))//判断用户发送验证码和注册用的是同一个邮箱
            {
                return(JsonNetResult(ResultStatus.EmailErr));
            }
            var user = this.UserService.GetList(t => t.EMail == eMail && t.Status == 0).FirstOrDefault();

            if (user == null)//判断注册的用户名是否存在
            {
                return(JsonNetResult(ResultStatus.EmailNoExist));
            }
            if (CacheHelper.Get("PwdBackCode") != null)
            {
                if (string.Compare(CacheHelper.Get("PwdBackCode").ToString(), code, true) == 0)
                {
                    bool res1 = CacheHelper.Remove("PwdBackCode");
                    bool res2 = CacheHelper.Remove("PwdBackCode");
                    if (res1 && res2)
                    {
                        return(JsonNetResult(ResultStatus.Success));
                    }
                }
            }
            return(JsonNetResult(ResultStatus.ValidateCodeErr));
        }
예제 #4
0
        public JsonNetResult GetPwdBackCode(string eMail)
        {
            if (!RegularHelper.IsEmail(eMail))//判断邮箱格式是否正确
            {
                return(JsonNetResult(ResultStatus.EmailErr));
            }
            var user = this.UserService.GetList(t => t.EMail == eMail && t.Status == 0).FirstOrDefault(); //判断邮箱是否存在,防止用户恶性发送邮件,禁用的用户不能找回密码

            if (user == null)                                                                             //判断邮箱是否存在
            {
                return(JsonNetResult(ResultStatus.EmailNoExist));
            }
            Tuple <string, bool> items = SendEmail(eMail, "创客教育官方", "创客教育用户找回密码验证码");
            string code    = items.Item1;
            bool   sendRes = items.Item2;

            if (sendRes)
            {
                bool res1 = CacheHelper.Set("PwdBackCode", code, DateTime.Now.AddSeconds(90));
                bool res2 = CacheHelper.Set("PwdBackEMail", eMail, DateTime.Now.AddSeconds(90));//判断用户发送验证码和注册用的是同一个邮箱
                if (res1 && res2)
                {
                    return(JsonNetResult(ResultStatus.Success));
                }
            }
            return(JsonNetResult(ResultStatus.Fail));
        }
예제 #5
0
        public JsonNetResult GetRegCode(string email)
        {
            //正则判断
            if (!RegularHelper.IsEmail(email))//判断邮箱格式是否正确
            {
                return(JsonNetResult(ResultStatus.EmailErr));
            }
            //账户状态判断
            var user = this.UserService.GetList(t => t.EMail == email && t.State > 0).FirstOrDefault(); //禁用账户的邮箱不能注册

            if (user != null)                                                                           //判断邮箱是否存在
            {
                return(JsonNetResult(ResultStatus.EmailExist));
            }
            Tuple <string, bool> items = SendEmail(email, "创客教育官方", "用户注册验证码");
            string code    = items.Item1;
            bool   sendRes = items.Item2;

            if (sendRes)
            {
                bool res1 = CacheHelper.Set("RegCode", code, DateTime.Now.AddSeconds(90));
                bool res2 = CacheHelper.Set("EMail", email, DateTime.Now.AddSeconds(90));//判断用户发送验证码和注册用的是同一个邮箱
                if (res1 && res2)
                {
                    return(JsonNetResult(ResultStatus.Success));
                }
            }
            return(JsonNetResult(ResultStatus.Fail));
        }
        /// <summary>
        /// 检查用户的邮箱是否存在
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        public JsonBackResult CheckUserData(string email)
        {
            var userdata = this._userService.GetList(s => s.EMail == email && s.Status == 1).FirstOrDefault();

            if (userdata == null)
            {
                return(JsonBackResult(ResultStatus.UserNoExist));
            }
            if (!RegularHelper.IsEmail(email))
            {
                return(JsonBackResult(ResultStatus.EmailErr));
            }

            Tuple <string, bool> items = SendEmail(email, "创客平台", "用户找回密码验证码");
            string code = items.Item1;

            Session.Add("FindVerifycode", code);
            bool sendRes = items.Item2;

            if (sendRes)
            {
                bool res1 = CacheHelper.Set("PwdBackCode", code, DateTime.Now.AddSeconds(90));
                bool res2 = CacheHelper.Set("PwdBackEmail", email, DateTime.Now.AddSeconds(90));
                if (res1 && res2)
                {
                    return(JsonBackResult(ResultStatus.Success));
                }
            }
            return(JsonBackResult(ResultStatus.Fail));
        }
예제 #7
0
        public JsonNetResult UpdataPwd(string newPwd, string eMail)
        {
            if (!RegularHelper.IsEmail(eMail))//判断邮箱格式是否正确
            {
                return(JsonNetResult(ResultStatus.EmailErr));
            }
            var user = this.UserService.GetList(t => t.Status == 1 && t.EMail == eMail).FirstOrDefault();

            if (user == null)
            {
                return(JsonNetResult(ResultStatus.EmailNoExist));
            }
            user.Password = EncryptionHelper.GetMd5Str(newPwd);
            int res = this.UserService.Update(user);

            if (res > 0)
            {
                return(JsonNetResult(ResultStatus.Success));
            }
            return(JsonNetResult(ResultStatus.Fail));
        }