protected override bool AuthorizeCore(HttpContextBase httpContext) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } IPrincipal user = httpContext.User; if (!user.Identity.IsAuthenticated) { return false; } string userRole = ""; /*var cookie = httpContext.Request.Cookies["UserRole"]; if (cookie != null) { userRole = cookie.Value; }*/ //TODO: caching var db = new DatabaseConnection2(); userRole = db.Customers.Find(user.Identity.Name).Role; return userRole.ToLower() == "admin"; }
protected override bool AuthorizeCore(HttpContextBase httpContext) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } IPrincipal user = httpContext.User; if (!user.Identity.IsAuthenticated) { return(false); } string userRole = ""; /*var cookie = httpContext.Request.Cookies["UserRole"]; * if (cookie != null) * { * userRole = cookie.Value; * }*/ //TODO: caching var db = new DatabaseConnection2(); userRole = db.Customers.Find(user.Identity.Name).Role; return(userRole.ToLower() == "admin"); }