Ejemplo n.º 1
0
        // GET: Order
        public ActionResult Index(string H)
        {
            if (H == null)
            {
                return(RedirectToAction("Login", ""));
            }
            string hash = H;

            if (!UserInfo.IsValid() || Session["userinfo"] == null || UserInfo.getHash() != H)
            {
                System.Data.Entity.Core.Objects.ObjectParameter validUser = new System.Data.Entity.Core.Objects.ObjectParameter("ValidUser", typeof(bool));

                try
                {
                    getUserDetails_Result ud = db.getUserDetails(hash, validUser).Single();
                    UserInfo.setDetails(ud.UserName, ud.FullName, ud.SupplierCode, ud.SupplierName, hash, ud.UserID, (int)ud.AdminLevel, ud.AdminLevelName);

                    Session["userinfo"] = UserInfo.Export();
                }
                catch (Exception e)
                {
                }
            }
            if (!UserInfo.IsValid())
            {
                return(RedirectToAction("Login", "Login"));
            }

            return(RedirectToAction("Summary"));

            //   return View();
        }
Ejemplo n.º 2
0
        public ActionResult Login(string UserName, string Password, string SupplierCode)
        {
            string ipAddress = "";

            ipAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (string.IsNullOrEmpty(ipAddress))
            {
                ipAddress = Request.ServerVariables["REMOTE_ADDR"];
            }


            System.Data.Entity.Core.Objects.ObjectParameter hashValue = new System.Data.Entity.Core.Objects.ObjectParameter("token", typeof(string));
            int rc = 0;

            System.Data.Entity.Core.Objects.ObjectParameter change_param = new System.Data.Entity.Core.Objects.ObjectParameter("change", "N");
            if (String.IsNullOrEmpty(Password) || Password == "monkey")
            {
                rc = db.loginUser(UserName, "monkey", SupplierCode, hashValue, ipAddress, change_param);

                if ((string)hashValue.Value != "0")
                {
                    TempData["hashreset"] = hashValue.Value;
                    System.Data.Entity.Core.Objects.ObjectParameter op = new System.Data.Entity.Core.Objects.ObjectParameter("validuser", 0);
                    getUserDetails_Result ud = db.getUserDetails((string)hashValue.Value, op).Single();

                    UserInfo.setDetails(ud.UserName, ud.FullName, ud.SupplierCode, ud.SupplierName, (string)hashValue.Value, ud.UserID, (int)ud.AdminLevel, ud.AdminLevelName);
                    assignViewBagDefaults();
                    return(RedirectToAction("Expired"));
                }
            }

            rc = db.loginUser(UserName, Password, SupplierCode, hashValue, ipAddress, change_param);

            ViewBag.Hash = hashValue.Value;

            if ((string)hashValue.Value != "0")
            {
                System.Data.Entity.Core.Objects.ObjectParameter op = new System.Data.Entity.Core.Objects.ObjectParameter("validuser", 0);

                getUserDetails_Result ud = db.getUserDetails((string)hashValue.Value, op).Single();

                UserInfo.setDetails(ud.UserName, ud.FullName, ud.SupplierCode, ud.SupplierName, (string)hashValue.Value, ud.UserID, (int)ud.AdminLevel, ud.AdminLevelName);

                if ((string)change_param.Value == "Y")
                {
                    return(RedirectToAction("Expired"));
                }
                return(RedirectToAction("index", "Order", new { H = hashValue.Value }));
            }
            ViewBag.LoginResult = "Login failed";
            return(View());
        }
Ejemplo n.º 3
0
        public ActionResult Reset()
        {
            System.Data.Entity.Core.Objects.ObjectParameter validUser = new System.Data.Entity.Core.Objects.ObjectParameter("ValidUser", typeof(bool));

            getUserDetails_Result ud = db.getUserDetails((string)TempData["hashreset"], validUser).Single();

            ViewBag.UserID = ud.UserID;
            assignViewBagDefaults();

            usr_getUser_Result usr = db.usr_getUser(ud.UserID).Single();

            if (usr != null)
            {
                usr.Password = "";
                return(View(usr));
            }

            return(View());
        }