Beispiel #1
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            //HttpCookie heighCookie = new HttpCookie("HeighCookie");
            //heighCookie.Expires = DateTime.Now.AddYears(1);
            //heighCookie.Value = model.BodyHeight.ToString();
            //this.Response.Cookies.Add(heighCookie);
            //AppMember.BodyHeight = model.BodyHeight;
            string userName = model.UserNo;
            string password = model.UserPwd;
            string yzmcode  = Request.Cookies["yzmcode"].Value;

            if (ValidateLogin(userName, password) == 0)
            {
                return(View());
            }
            else if (yzmcode.ToLower() != model.TxtCheckCode.ToLower())
            {
                ModelState.AddModelError("TxtCheckCode", AppMember.AppText["CheckCodeError"]);
                return(View());
            }
            else if (ValidateLogin(userName, password) == -1)
            {
                ViewData["Message"] = AppMember.AppText["LoginErr"];
                return(View());
            }
            //FormsAuthenticationTicket authTicket = new
            //                FormsAuthenticationTicket(1, //version
            //                userName, // user name
            //                DateTime.Now,             //creation
            //                DateTime.Now.AddMinutes(30), //Expiration
            //                false, //Persistent
            //                userName); //since Classic logins don't have a "Friendly Name"

            //string encTicket = FormsAuthentication.Encrypt(authTicket);
            //this.Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));

            FormsAuthentication.SetAuthCookie(userName, false);
            FormsAuthentication.RedirectFromLoginPage(userName, false);

            SetBooksRepository rep = new SetBooksRepository();

            Session["CurSetBooks"] = rep.GetCurSetBooks(model.SetBooks);
            Session.Timeout        = 30;

            string userNa = UserRepository.GetUserName(userName);

            AppLog.WriteLog(userNa, LogType.Info, "Login", string.Format(AppMember.AppText["LogLogin"]));

            if (!String.IsNullOrEmpty(returnUrl))
            {
                return(Redirect(returnUrl));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Beispiel #2
0
 protected override IMasterFactory CreateRepository()
 {
     Repository = new SetBooksRepository();
     return(new MasterRepositoryFactory <SetBooksRepository>(Repository));
 }