예제 #1
0
 public ActionResult SetStore(String storeCode)
 {
     try
     {
         // Check the length of the store code. Limiting to 50 characters.
         if (storeCode.Length > 50)
         {
             throw new Exception("Bad store code");
         }
         // Check the store code to see if it's real. SQL Injection is handled by using a stored procedure.
         List <StoreInfo> storeList = DBAdapter.getInstance().GetStoreInfoByStoreCode(storeCode);
         // If the store code is a real store code, list size will be > 0
         if (storeList.Count() > 0)
         {
             // real store, set the cookie, and redirect to login page
             SessionAdapter.getInstance().SetCurrentStore(storeList[0], Response);
         }
         else
         {
             // not a real store, redirect to ChooseStore
             throw new Exception("Bad store code");
         }
     } catch (Exception e)
     {
         return(RedirectToAction("ChooseStore", "Login"));
     }
     // clear last logged in user.
     SessionAdapter.getInstance().SetLastLoggedInUser(null, this.Response);
     return(this.RedirectToAction("Index", "Login"));
 }
예제 #2
0
        public ActionResult LogUserIn(LoginModel login)
        {
            string adPath = ConfigurationManager.AppSettings["connection_ldap"]; //Path to your LDAP directory server

            ViewBag.ldapaddress = adPath;
            LdapAuthentication adAuth = new LdapAuthentication(adPath);

            try
            {
                bool authed = false;
                authed = adAuth.IsAuthenticated("flinc", login.UserName, login.Password);
                if (authed)
                {
                    // authorized
                    User loggedInUser = DBAdapter.getInstance().GetUserByUsername(login.UserName);
                    SessionAdapter.getInstance().LoggedInUser = loggedInUser;
                    // Set the cookie
                    FormsAuthentication.SetAuthCookie(login.UserName, true);
                    ViewBag.hasBeenLoggedIn = "true";
                }
            }
            catch (Exception ex)
            {
                // fail
                ModelState.AddModelError("", "The user name or password provided is incorrect.");
                ViewBag.hasBeenLoggedIn = "false";
            }
            return(View());
        }
예제 #3
0
 public ActionResult Index()
 {
     @ViewBag.customerTypes   = this.getCustomerTypes();
     @ViewBag.user            = SessionAdapter.getInstance().LoggedInUser;
     @ViewBag.associates      = DBAdapter.getInstance().GetAllUsers();
     @ViewBag.associateImages = this.PrepareAssociateImages(@ViewBag.associates);
     return(View());
 }
예제 #4
0
        public ActionResult GetSiteAreas()
        {
            ProductService  serv      = WebServiceUtils.GetEndpointService <ProductService>(ProductServiceInfo.ENDPOINT_NAME);
            List <SiteArea> siteAreas = serv.SiteAreasForStoreCode(SessionAdapter.getInstance().GetCurrentStore(this.Request));

            ViewBag.siteAreas = siteAreas;
            return(View());
        }
예제 #5
0
        public ActionResult Index()
        {
            StoreInfo store = SessionAdapter.getInstance().GetCurrentStore(Request);

            try
            {
                if (store.StoreCode == null)
                {
                    throw new Exception("Storecode is null, we need storecode to continue");
                }
                this.users          = DBAdapter.getInstance().GetUsersByStoreCode(store.StoreCode);
                @ViewBag.users      = this.users;
                @ViewBag.storeCodes = this.storeCodes;
            }
            catch (Exception e)
            {
                return(this.RedirectToAction("ChooseStore", "Login"));
            }
            return(View());
        }
예제 #6
0
        //
        // GET: /Home/

        public ActionResult Index()
        {
            @ViewBag.user = SessionAdapter.getInstance().LoggedInUser;
            return(View());
        }