Ejemplo n.º 1
0
        public ActionResult Login(User model)
        {
            try
            {
                if (Session["username"] != null)
                {
                    return(RedirectToAction("Index", "User"));
                }
                var user = db.User.FirstOrDefault(i => i.Username == model.Username);

                if (user == null)
                {
                    return(View(model));
                }
                var parola = usc.Decrypt(user.Password);

                if (parola != model.Password)
                {
                    return(View(model));
                }

                Session["userId"]   = user.ID;
                Session["userRole"] = user.RoleID;
                Session["username"] = user.Username;
                if (user.PicturePath == null)
                {
                    Session["userPic"] = "admin.ico";
                }
                else
                {
                    Session["userPic"] = user.PicturePath;
                }
                usc.CreateActionLog(Session["userId"].ToString(), "", " giriş yaptı.");
                return(RedirectToAction("Index", "User"));
            }
            catch
            {
                return(RedirectToAction("ErrorPage", "Home", new { error = "Bir Hata Oldu!" }));
            }
        }
Ejemplo n.º 2
0
 //Profil güncellemek için kullanılır.
 public ActionResult ProfilGuncelle()
 {
     try
     {
         string           username  = Session["username"].ToString();
         var              kullanici = db.User.Where(i => i.Username == username).SingleOrDefault();
         UserSessionClass usc       = new UserSessionClass();
         kullanici.Password = usc.Decrypt(kullanici.Password);
         return(View(kullanici));
     }
     catch
     {
         return(RedirectToAction("ErrorPage", "Home", new { error = "Bir Hata Oldu!" }));
     }
 }