Esempio n. 1
0
        // GET: Admin/Login
        public ActionResult Index()
        {
            DaoLogin  daoLogin  = new DaoLogin();
            UserLogin userLogin = new UserLogin();

            if (Request.Cookies[Pittmark.Common.Constraints.User_Login] != null)
            {
                string originUserName = Request.Cookies[Pittmark.Common.Constraints.User_Login].Value.Split('&')[0].Split('=')[1];
                string originPassword = Request.Cookies[Pittmark.Common.Constraints.User_Login].Value.Split('&')[1].Split('=')[1];
                if (daoLogin.CheckLogin(originUserName, originPassword))
                {
                    userLogin.UserName = originUserName;
                    userLogin.Password = originPassword;
                    Session[Pittmark.Common.Constraints.User_Login] = userLogin;
                    Session.Timeout = 10000;
                    return(RedirectToAction("ManageProfile", "Home"));
                }
            }
            if (Session[Pittmark.Common.Constraints.User_Login] != null)
            {
                userLogin = (UserLogin)Session[Pittmark.Common.Constraints.User_Login];
                if (daoLogin.CheckLogin(userLogin.UserName, userLogin.Password))
                {
                    return(RedirectToAction("ManageProfile", "Home"));
                }
            }
            return(View());
        }
Esempio n. 2
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            DaoLogin  daoLogin  = new DaoLogin();
            UserLogin userLogin = new UserLogin();

            if (Request.Cookies[Pittmark.Common.Constraints.User_Login] != null)
            {
                string originUserName = Request.Cookies[Pittmark.Common.Constraints.User_Login].Value.Split('&')[0].Split('=')[1];
                string originPassword = Request.Cookies[Pittmark.Common.Constraints.User_Login].Value.Split('&')[1].Split('=')[1];
                if (daoLogin.CheckLogin(originUserName, originPassword))
                {
                    userLogin.UserName = originUserName;
                    userLogin.Password = originPassword;
                    Session[Pittmark.Common.Constraints.User_Login] = userLogin;
                    Session.Timeout = 10000;

                    return;
                }
            }
            if (Session[Pittmark.Common.Constraints.User_Login] != null)
            {
                userLogin = (UserLogin)Session[Pittmark.Common.Constraints.User_Login];
                if (daoLogin.CheckLogin(userLogin.UserName, userLogin.Password))
                {
                    return;
                }
            }
            filterContext.Result = RedirectToAction("Index", "Login", new { area = "Admin" });
        }
        public ViewResult ChangePassword(AdminViewModel adminViewModel)
        {
            DaoLogin daoLogin = new DaoLogin();

            if (daoLogin.CheckLogin(adminViewModel.UserName, adminViewModel.OldPassword))
            {
                if (adminViewModel.NewPassword == adminViewModel.EnterNewPassword && !string.IsNullOrEmpty(adminViewModel.EnterNewPassword))
                {
                    DaoAdminInformation daoAdmin = new DaoAdminInformation();
                    if (daoAdmin.ChangePassword(adminViewModel.UserName, adminViewModel.NewPassword))
                    {
                        return(View("PersonalInformation"));
                    }
                    ModelState.AddModelError("", "Thay đổi không thành công");
                    return(View("PersonalInformation"));
                }
                ModelState.AddModelError("", "Mật khẩu không trùng nhau");
                return(View("PersonalInformation"));
            }
            else
            {
                ModelState.AddModelError("", "Mật khẩu cũ không đúng");
                return(View("PersonalInformation"));
            }
        }
Esempio n. 4
0
        public int CheckLogin()
        {
            var daObject = new DaoLogin();
            int vcl      = daObject.CheckLogin(EmailLogin, Password);

            if (vcl != 0)
            {
                return(vcl);
            }
            return(0);
        }
Esempio n. 5
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string taiKhoan = txtTaiKhoan.Text;
            string matKhau  = txtMatKhau.Text;

            if (daoLogin.CheckLogin(taiKhoan, matKhau))
            {
                UserLogin.UserName = taiKhoan;
                UserLogin.PassWord = matKhau;
                DashBoard dashBoard = new DashBoard(this, UserLogin);
                dashBoard.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Bạn nhập sai thông tin", "Cảnh báo", MessageBoxButtons.OK);
            }
        }
Esempio n. 6
0
        public ActionResult Login(UserLogin userLogin)
        {
            if (ModelState.IsValid)
            {
                DaoLogin daoLogin = new DaoLogin();
                if (daoLogin.CheckLogin(userLogin.UserName, userLogin.Password))
                {
                    Session[Pittmark.Common.Constraints.User_Login] = userLogin;
                    Session.Timeout = 10000;
                    if (userLogin.SavePassWork)
                    {
                        HttpCookie userInfo = new HttpCookie(Pittmark.Common.Constraints.User_Login);
                        userInfo["username"] = userLogin.UserName;
                        userInfo["password"] = userLogin.Password;
                        Response.Cookies.Add(userInfo);
                    }

                    return(RedirectToAction("ManageProfile", "Home"));
                }
                ModelState.AddModelError("", "Tài khoản và mật khẩu không hợp lệ");
            }

            return(View("Index"));
        }