Esempio n. 1
0
        private bool ValidateAdminPriv()
        {
            string debugMode = ConfigurationManager.AppSettings["debugMode"];

            if (debugMode == "true")
            {
                return(true);
            }

            HttpCookie authcookie = Request.Cookies[FormsAuthentication.FormsCookieName];

            if (authcookie == null)
            {
                RedirectToMenu();
            }

            FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authcookie.Value);

            if (ticket == null)
            {
                RedirectToMenu();
            }

            Helpers.AdminService service = new Helpers.AdminService();

            service.AddAdmin(new Models.AdminsGridView()
            {
                Address = ticket.Name,
                Status  = false
            });

            HashSet <string> admins = service.GetAdminHash();

            var rawUserName = service.ParseRawUserName(ticket.Name);

            if (admins.Contains(rawUserName.ToUpper()))
            {
                Session["username"] = rawUserName;
                return(true);
            }


            return(false);
        }