Exemple #1
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));
        }
Exemple #2
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));
        }
        private void SendMail(Ad ad, object reservation)
        {
            EmailSend emailSend = new EmailSend();

            emailSend.SendEmail(ad, reservation);
            emailSend.CloseConnection();
        }
Exemple #4
0
        /// <summary>
        /// SendEmail - method for sending email notification
        /// </summary>
        /// <param name="log"></param>
        private void SendEmail(string subject, string body)
        {
            EmailSend email = new EmailSend();

            email.From       = "";
            email.To         = "";
            email.Subject    = subject;
            email.Body       = body;
            email.Port       = 25;
            email.SMTPClient = "";
            email.SendEmail();
        }
Exemple #5
0
        public async Task <ActionResult <registration> > Postregistration(registration registration)
        {
            EmailSend em   = new EmailSend();
            Random    rn   = new Random();
            int       Pswd = rn.Next(1000);
            string    PSW  = Pswd.ToString();

            registration.Password = Pswd;
            em.SendEmail(registration.Email, PSW, "Your password");
            _context.uregister.Add(registration);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Getregistration", new { id = registration.Id }, registration));
        }