Beispiel #1
0
        // GET: Home
        public ActionResult Index(int Page = 1)
        {
            if (Session["uyeid"] == null && Request.Cookies["membid"] != null)
            {
                Session["uyeid"]        = AESCryptoSec.Decrypt(Request.Cookies["membid"].Value, Helper.AesKey);
                Session["kullaniciadi"] = AESCryptoSec.Decrypt(Request.Cookies["membad"].Value, Helper.AesKey);
                Helper.ActiveUser       = db.Uye.Find(Convert.ToInt32(Session["uyeid"]));
            }
            var makale = db.Makale.Where(x => x.OnayDurum == true && x.Durum == true).OrderByDescending(x => x.Tarih).ToPagedList(Page, 3);

            return(View(makale));
        }
Beispiel #2
0
        public ActionResult Login(Uye uye)
        {
            if (String.IsNullOrEmpty(uye.KullaniciAdi) || String.IsNullOrEmpty(uye.Sifre))
            {
                TempData["HataliGiris"] = "Kullanıcı adı ya da şifre boş bırakılamaz!";
                return(View());
            }

            uye.Sifre = Sec.MD5Hex(uye.Sifre).ToLower();
            var login = db.Uye.Where(u => u.KullaniciAdi == uye.KullaniciAdi).SingleOrDefault();

            if (login == null)
            {
                TempData["HataliGiris"] = "Girdiğiniz kullanıcı veya şifre hatalı";
                return(View());
            }
            else if (login.KullaniciAdi == uye.KullaniciAdi && login.Sifre == uye.Sifre && login.Durum == true)
            {
                //Beni hatırla

                HttpCookie kuki = new HttpCookie("membad");
                kuki.Value   = AESCryptoSec.Encrypt(login.KullaniciAdi, Helper.AesKey);
                kuki.Expires = DateTime.Now.AddDays(10);
                Response.Cookies.Add(kuki);

                HttpCookie kuki2 = new HttpCookie("membid");
                kuki2.Value   = AESCryptoSec.Encrypt(login.UyeID.ToString(), Helper.AesKey);
                kuki2.Expires = DateTime.Now.AddDays(10);
                Response.Cookies.Add(kuki2);

                Helper.ActiveUser       = login;
                Session["uyeid"]        = login.UyeID;
                Session["kullaniciadi"] = login.KullaniciAdi;
                Session["yetkiid"]      = login.YetkiID;

                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                TempData["HataliGiris"] = "Girdiğiniz kullanıcı veya şifre hatalı";
                return(View());
            }
        }