Example #1
0
        public ActionResult Login(string userCode, string password, bool rememberMe)
        {
            SysUserDAO userDAO = new SysUserDAO(this.mapper);
            SysUserLoginModels loginUser = new SysUserLoginModels();
            loginUser.userCode = userCode;
            loginUser.password = password;
            SysUserModels user;
            if (ModelState.IsValid)
            {
                if (userDAO.NormalUserLogin(loginUser, out user))
                {
                    this.persistUser(user, rememberMe);
                    FormsAuthentication.SetAuthCookie(loginUser.userCode, rememberMe);

                    Session.Add("UserSession", user);
                    userDAO.SetLastLoginTime(userCode);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    TempData["errorMessage"] = PsMModel.Resource.MsgLoginFailed;
                    return RedirectToAction("Index", "Home");
                }
            }
            else
            {
                return RedirectToAction("Index", "Home");
            }
        }
Example #2
0
 public ActionResult Index()
 {
     SysUserSearchModels userList = new SysUserSearchModels();
     SysUserDAO userDAO = new SysUserDAO(this.mapper);
     userList.pageIndex = 1;
     userList = userDAO.searchUser(userList);
     return View(userList);
 }
Example #3
0
        public ActionResult Active(string u, string k)
        {
            SysUserDAO sysUserDAO = new SysUserDAO(this.mapper);

            if (sysUserDAO.ActivateUser(u, k))
            {
                ViewData["active"] = "true";
            }
            else
            {
                ViewData["active"] = "false";
            }
            return View();
        }
Example #4
0
 public ActionResult UserLogin(SysUserLoginModels loginUser)
 {
     SysUserDAO userDAO = new SysUserDAO(this.mapper);
     SysUserModels user;
     if (ModelState.IsValid)
     {
         if (userDAO.AdminUserLogin(loginUser, out user))
         {
             FormsAuthentication.SetAuthCookie(loginUser.userCode, false);
             Session.Add("UserSession", user);
             return RedirectToAction("Index", "News");
         }
         else
         {
             return View("Index", "Home");
         }
     }
     else
     {
         return View("Index", "Home");
     }
 }
Example #5
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            mapper = MyMapper.Instance();
            mapper.BeginTransaction(System.Data.IsolationLevel.Serializable);

            if (Session["UserSession"] == null || !Session.IsNewSession) {
                HttpCookie cookie = Request.Cookies[FormsAuthentication.FormsCookieName];
                if (cookie != null)
                {
                    FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value);
                    if (ticket.IsPersistent)
                    {
                        SysUserDAO sysUserDAO = new SysUserDAO(this.mapper);
                        SysUserModels user = sysUserDAO.GetUserByUserCode(ticket.Name);
                        if (user != null)
                        {
                            FormsAuthentication.SetAuthCookie(user.userCode, true);
                            Session["UserSession"] = user;
                        }
                    }
                }
            }
            base.OnActionExecuting(filterContext);
        }
Example #6
0
 public ActionResult ChangePassword(SysUserChangePasswordModels changePassword)
 {
     SysUserDAO userDAO = new SysUserDAO(this.mapper);
     userDAO.ChangePassword(changePassword);
     return View(changePassword);
 }
Example #7
0
 public ActionResult ViewUser(string userCode)
 {
     SysUserDAO userDAO = new SysUserDAO(this.mapper);
     SysUserViewModels model = new SysUserViewModels();
     model = userDAO.getUserView(userCode, model);
     return View(model);
 }
Example #8
0
 public ActionResult Search(SysUserSearchModels userList)
 {
     SysUserDAO userDAO = new SysUserDAO(this.mapper);
     userList = userDAO.searchUser(userList);
     return View("Index", userList);
 }
Example #9
0
 public ActionResult SaveAccess(SysUserViewModels model)
 {
     MstIndexTypeUserDAO indexTypeUserDAO = new MstIndexTypeUserDAO(this.mapper);
     SysUserModels userSession = (SysUserModels) Session["UserSession"];
     if (indexTypeUserDAO.SaveIndexTypeUser(model, userSession.userCode, Constants.TransactionType.Bank))
     {
         return RedirectToAction("ViewUser", "User", new { userCode = model.userCode });
     }
     else
     {
         SysUserDAO userDAO = new SysUserDAO(this.mapper);
         model = userDAO.getUserView(model.userCode, model);
         return View("ViewUser", model);
     }
 }
Example #10
0
 public ActionResult Register(SysUserRegisterModels model, Boolean captchaValid)
 {
     ViewData["NotShowLoginForm"] = "true";
     if (ModelState.IsValid && captchaValid)
     {
         SysUserDAO sysUserDAO = new SysUserDAO(this.mapper);
         if (sysUserDAO.RegisterUser(model))
         {
             return View("RegisterSuccess");
         }
     }
     if (!captchaValid)
     {
         model.errorMessage = PsMModel.Resource.MsgErrCaptchaNotMatch;
     }
     model.birthDateList = DateUtils.genDateList();
     model.birthMonthList = DateUtils.genMonthList();
     model.birthYearList = DateUtils.genYearList();
     model.userCode = string.Empty;
     model.userPassword = string.Empty;
     model.agreeRule = false;
     return View(model);
 }
Example #11
0
 public ActionResult Profile(SysUserProfileModels model)
 {
     SysUserDAO userDAO = new SysUserDAO(this.mapper);
     userDAO.UpdateUser(model);
     model.birthDateList = DateUtils.genDateList();
     model.birthMonthList = DateUtils.genMonthList();
     model.birthYearList = DateUtils.genYearList();
     return View(model);
 }
Example #12
0
        public ActionResult Profile()
        {
            SysUserDAO userDAO = new SysUserDAO(this.mapper);
            SysUserModels user = (SysUserModels)Session["UserSession"];
            user = userDAO.GetUserByUserCode(user.userCode);
            SysUserProfileModels model = userDAO.GetUserProfile(user);

            return View(model);
        }
Example #13
0
 public ActionResult ResetPassword(SysUserLostPasswordModels model)
 {
     if (ModelState.IsValid)
     {
         SysUserDAO userDAO = new SysUserDAO(this.mapper);
         userDAO.ResetPassword(model);
     }
     return View(model);
 }