public ActionResult Login(LoginModel form)
        {
            string _SubSystemID = Request.Form["SubSystemID"];
            string _SubSystemDesc = Request.Form["SubSystemDesc"];

            var user = _F98021Manager.getUserInfo(form.UserID);

            if (_SecurityManager.checkSecurityUser(form.UserID, 8))
            {
                if (user == null || !_F98021Manager.CheckUserLogin(form.UserID, form.Password))
                {
                    ModelState.AddModelError("*", "The user name or password provided is incorrect.");
                    return View(new LoginModel { UserID = form.UserID })
                            .WithErrorMessage("Invalid username or password.");
                }
            }
            else
            {
                ModelState.AddModelError("*", "The user ID is not in the list.");
                return View(new LoginModel { UserID = form.UserID })
                        .WithErrorMessage("Invalid User ID.");
            }

            FormsAuthentication.SetAuthCookie(form.UserID, true);

            //SecurityUtils.SetAuthCookies(form.UserID, "User Name", 8, "ARTracking");

            HttpCookie LoginDetail = new HttpCookie("LoginDetail");
            LoginDetail.Values["SubSystemID"] = _SubSystemID;
            LoginDetail.Values["SubSystemName"] = _SubSystemDesc;
            LoginDetail.Expires = DateTime.Today.AddDays(2);

            HttpContext.Response.SetCookie(LoginDetail);

            //Request.Cookies.Add(LoginDetail);

            switch (_SubSystemID)
            {
                case "7":
                    return RedirectToAction("Index", "Customer");
                case "8":
                    return RedirectToAction("Index", "ARTracking");
                case "9":
                    return RedirectToAction("Index", "Home", new { Area = "ContractPricing" });
                default:
                    return View();

            }
        }
Exemplo n.º 2
0
        public LoginModel getUserInfo(string UserID)
        {
            Mapper.CreateMap<F98021, LoginModel>();

            objF98021 = new F98021Repository();
            LoginModel objResult = new LoginModel();

            if (objF98021.GetAll(u => u.UserID.Equals(UserID)).Count() > 0)
            {
                F98021 objEntity = objF98021.GetSingle(u => u.UserID.Equals(UserID));
                objResult = Mapper.Map(objEntity, objResult);
            }

            return objResult;
        }