Example #1
0
        public ActionResult Login()
        {
            LoginForm form = new LoginForm();
            //todo: Check session user existed or not ?
            string ss_username = (string)Session[AppStoreData.PAR.USR_LOG];
            wpUser userLogin   = null;
            bool   isLoggedIn  = false;

            if (ss_username != null)
            {
                //todo: Logged in
                userLogin  = userRep.getUser(ss_username);
                isLoggedIn = true;
            }

            //todo: need to enhance less code
            //todo: put userlogin to model to display?
            if (!isLoggedIn)
            {
                ViewBag.MGS_AUTHFAIL_VAL = TempData[AppStoreData.PAR.MGS_AUTHFAIL];
                return(PartialView("LoginFormPartial", form));
            }
            else
            {
                ViewBag.userlogin = userLogin;
                return(PartialView("UserInformationPartial", form));
            }
        }
Example #2
0
        public ActionResult Login(LoginForm form)
        {
            bool   isAuthen = userRep.authenticateUser(form.Username, form.Password);
            wpUser user     = null;

            if (isAuthen)
            {
                //todo: Do login stuff
                user = userRep.getUser(form.Username);
                userRep.saveLastLogin(form.Username);
                Session[AppStoreData.PAR.USR_LOG] = form.Username;
            }
            else
            {
                TempData[AppStoreData.PAR.MGS_AUTHFAIL] = AppStoreData.PAR.MGS_AUTHFAIL_VAL;
            }

            return(RedirectToAction("Index", "Home"));
        }