Пример #1
0
        public ActionResult Login(cvmLogin model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.Message = "Account or Password Error!!";
                return(View(model));
            }

            string str_password = model.UserPassword;

            using (Cryptographys cryp = new Cryptographys())
            {
                str_password = cryp.SHA256Encode(str_password);
            }

            var users = db.users
                        .Where(m => m.maccount == model.UserAccount)
                        .Where(m => m.mpassword == str_password)
                        .FirstOrDefault();

            if (users == null)
            {
                UserAccount.LogOut();
                FormsAuthentication.SignOut();
                ViewBag.Message = "帳號或密碼錯誤!";
                return(View(model));
            }

            UserAccount.Login(users, UserAccount.GetRoleNo(users.role_no));
            UserAccount.IsRememberMe = model.Remember;
            UserAccount.LoginAuthenticate();

            return(RedirectToAction("RedirectToUserPage"));
        }
Пример #2
0
        public ActionResult Login(cvmLogin model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            string str_password = model.Password;

            using (Cryptographys crpy = new Cryptographys())
            {
                str_password = crpy.SHA256Encode(str_password);
            }
            var users = db.Users
                        .Where(m => m.mno == model.UserNo)
                        .Where(m => m.password == str_password)
                        .FirstOrDefault();

            if (users == null)
            {
                return(View(model));
            }
            UserAccount.Login(model.UserNo, users.mname, UserAccount.GetRoleNo(users.role_no));

            return(RedirectToAction("RedirectToUserPage"));
        }
Пример #3
0
 public ActionResult Login()
 {
     UserAccount.LogOut();
     cvmLogin model = new cvmLogin()
     {
         UserNo = "",
         Password = "",
         Remember = false
     };
     return View(model);
 }
Пример #4
0
        public ActionResult Login()
        {
            if (UserAccount.IsAuthenticated)
            {
                UserAccount.Login(UserAccount.GetIdentityValue(enIdentityType.Name));
                if (UserAccount.IsLogin)
                {
                    return(View("LoginClear"));
                }
            }

            cvmLogin model = new cvmLogin()
            {
                UserAccount  = "",
                UserPassword = "",
                Remember     = false,
                ErrorMessage = "xxxx"
            };

            return(View("Login", model));
        }