Example #1
0
        public ActionResult Login(RegisterPack doctor)
        {
            ViewBag.IsLogin = false;
            PezeshkPlusEntities db        = new PezeshkPlusEntities();
            List <int?>         CheckMail = db.USP_SEL_Email(doctor.LoginModel.Email).ToList();

            if (CheckMail.Count == 0)
            {
                TempData["WrongEmail"] = "ایمیل وارد شده صحیح نمی باشد!";
                return(RedirectToAction("Register"));
            }

            List <int?> CheckPass = db.USP_SEL_Password(doctor.LoginModel.Email, doctor.LoginModel.Password).ToList();

            if (CheckPass.Count == 0)
            {
                TempData["WrongPass"] = "******";
                return(RedirectToAction("Register"));
            }

            List <bool?> IsActive = db.USP_SEL_IsDoctorActive(doctor.LoginModel.Email).ToList();

            if (IsActive[0] == false)
            {
                TempData["NotActive"] = "ثبت نام شما هنوز توسط مدیریت تایید نشده!";
                return(RedirectToAction("Register"));
            }

            string authID = Guid.NewGuid().ToString();

            Session["AuthID"] = authID;

            Response.Cookies["AuthID"].Value = authID;

            Session[authID]        = doctor.LoginModel.Email;
            Session[authID + "IP"] = Request.UserHostAddress;

            string previousUrl = Session["PreviousUrl"].ToString();

            Session.Remove("PreviousUrl");

            return(Redirect(previousUrl));
        }