Пример #1
0
        public ActionResult LogIn()
        {
            if (Session.CurrentUser() != null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                var model = new LoginModel();

                HttpCookie cookie = HttpContext.Request.Cookies[Constant.BCS_LOGIN_INFO];
                if (cookie != null && cookie.Expires >= DateTime.Now)
                {
                    model.UserName = string.IsNullOrEmpty(cookie.Values[Constant.BCS_LOGIN_USERNAME])
                                    ? string.Empty
                                    : SecurityMethod.Base64Decode(cookie.Values[Constant.BCS_LOGIN_USERNAME]);

                    model.Password = string.IsNullOrEmpty(cookie.Values[Constant.BCS_LOGIN_PASSWORD])
                                    ? string.Empty
                                    : SecurityMethod.Base64Decode(cookie.Values[Constant.BCS_LOGIN_PASSWORD]);

                    // LogIn
                    SecurityService.Login(model.UserName.Trim(), model.Password.Trim(), model.RememberMe);
                }
                return(View(model));
            }
        }
Пример #2
0
        public ActionResult Index()
        {
            if (Session.CurrentUser() != null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                var model = new LoginModel();

                HttpCookie cookie = Request.Cookies[Constant.BCS_LOGIN_INFO];
                if (cookie != null)
                {
                    model.UserName = string.IsNullOrEmpty(cookie.Values[Constant.BCS_LOGIN_USERNAME])
                                     ? string.Empty
                                     : SecurityMethod.Base64Decode(cookie.Values[Constant.BCS_LOGIN_USERNAME]);

                    model.Password = string.IsNullOrEmpty(cookie.Values[Constant.BCS_LOGIN_PASSWORD])
                                     ? string.Empty
                                     : SecurityMethod.Base64Decode(cookie.Values[Constant.BCS_LOGIN_PASSWORD]);
                }
                return(View("Login", model));
            }
        }