예제 #1
0
        public ActionResult GetPassword(GetPasswordModel model)
        {
            if (ModelState.IsValid)
            {
                int memberAction = (int)MemberActionType.GetPassword;
                int limitMin = Convert.ToInt32(ConfigSetting.GetPasswordEmailTimeDiffMin);
                if (memberService.HasGetPasswordActionInLimitTime(model, limitMin, memberAction))
                {
                    ViewBag.SendMail = true;
                    ViewBag.HasSendMail = true;
                    ViewBag.Message = limitMin;
                }
                else
                {
                    Member member = memberService.FindMemberByEmail(model.Email);
                    string userKey = Guid.NewGuid().ToString();

                    EmailModel em = emailService.GetResetPasswordMail(member.MemberID, member.Email, member.NickName, userKey);
                    emailService.SendMail(em);

                    member_ActionService.Create(member, memberAction, userKey);

                    ViewBag.HasSendMail = false;
                    ViewBag.SendMail = true;
                    ViewBag.Title = "";
                }
                return View(model);

            }
            return View(model);
        }
예제 #2
0
 public bool HasGetPasswordActionInLimitTime(GetPasswordModel model, int limitMin, int memberAction)
 {
     DateTime LimitDate = DateTime.Now.AddMinutes(-(limitMin));
     string IP = HttpHelper.IP;
     var query = DB_Service.Set<Member>()
         .Include(x => x.Member_Action)
         .Where(x =>
             (x.Member_Action.Any(ma =>
                 ma.ActionType == memberAction
                 && ma.AddTime > LimitDate
                 && ma.IP == IP
                 )) && x.Email.Equals(model.Email, StringComparison.OrdinalIgnoreCase));
     return query.Count() > 0;
 }