Esempio n. 1
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            var controller = filterContext.RequestContext.RouteData.Values["Controller"];
            var action     = filterContext.RequestContext.RouteData.Values["Action"];

            if (Session["User"] == null)
            {
                filterContext.Result = new RedirectResult("/home/index/");
            }
            else
            {
                //VaporStores.Classes.Logging.WriteToLog(controller.ToString() + ":" + action.ToString(), Session["SessionGUID"].ToString(),
                //                            ((VaporStoresData.PersonStoreRole)Session["User"]).Person.UserName.ToLower(),
                //                            ((VaporStoresData.PersonStoreRole)Session["User"]).Store.StoreID);


                if (Session["User"] != null && Session["Business"] != null)
                {
                    this.Associate = (AHDDManagerClass.Associate)Session["User"];
                    this.Associate.AssociateBusiness = (AHDDManagerClass.Business)Session["Business"];

                    return;
                }
                else
                {
                    filterContext.Result = new RedirectResult("/home/index/");
                    return;
                }
            }
        }
Esempio n. 2
0
        public ActionResult Login(string UserName, string Password)
        {
            try
            {
                AHDDManagerClass.Associate objA = new AHDDManagerClass.Associate(UserName, Password);
                AHDDManagerClass.Business  objB;

                if (objA.AssociatesExist)
                {
                    objB = new AHDDManagerClass.Business(objA.BusinessID);

                    if (objB.BusinessesExist)
                    {
                        Session["Associate"] = objA;

                        Session["Business"] = objB;

                        Models.Logging.LogClockIn("User Logged in: " + objA.UserName + " (" + objA.FirstName + " " + objA.LastName + ")", objA.UserName);

                        Session.Timeout = 600;

                        return(Json("0"));
                    }
                    else
                    {
                        Models.Logging.LogClockIn("User LOGGED in. Could not find business: " + objA.UserName + " (" + objA.FirstName + " " + objA.LastName + ") | " + objA.BusinessID, objA.UserName);
                        return(Json("There was an error logining in."));
                    }
                }
                else
                {
                    Models.Logging.LogClockIn("User Login FAILED: " + UserName + " | " + Password, objA.UserName);
                    return(Json("Login failed."));
                }
            }
            catch
            {
                Models.Logging.LogClockIn("User Login FAILED: " + UserName + " | " + Password, UserName);
                return(Json("There was an error logining in."));
            }
        }