/// <summary> /// Initializes a new instance of the <see cref="FilterDescriptor"/> class. /// </summary> /// <param name="filterType">Type of the filter.</param> /// <param name="when">The flag that defines when it should run.</param> /// <param name="executionOrder">The execution order.</param> /// <param name="attribute">The attribute.</param> public FilterDescriptor(Type filterType, ExecuteWhen when, int executionOrder, FilterAttribute attribute) { this.filterType = filterType; this.when = when; this.executionOrder = executionOrder; this.attribute = attribute; }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { /* ArrayList admins = new ArrayList(); admins.Add("jpino"); admins.Add("logas"); admins.Add("lmolina"); if (admins.Contains (context.CurrentUser.Identity.Name.ToLower())) return true; else { context.Flash["TypeMsg"] = "alert alert-error"; context.Flash["Msg"] = "Error : No eres admin"; context.Response.RedirectToUrl ("/"); return false; } */ if (context.CurrentUser.IsInRole ("admin")) return true; else { context.Flash["TypeMsg"] = "alert alert-error"; context.Flash["Msg"] = "Error : No eres admin"; context.Response.RedirectToUrl ("/"); return false; } }
/// <summary> </summary> public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { if (context.Request.IsLocal) { return(true); } // Read previous authenticated principal from session // (could be from cookie although with more work) User user = (User)context.Session["user"]; // Sets the principal as the current user context.CurrentUser = user; if (Controllers.BaseController.authenticated()) { return(true); } // Checks if it is OK // if (context.CurrentUser == null || // !context.CurrentUser.Identity.IsAuthenticated || // !Authentication.logged_in()) // { if (Controllers.BaseController.authenticated()) { // Not authenticated, redirect to login String username = System.Web.HttpContext.Current.Response.Cookies["unldap"].Value; context.Session["authusername"] = username; //context.CurrentController.PropertyBag["authusername"] = username; // further filter if necessary } // Everything is ok return(true); }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { ArHelper.WithSession(s => { var regionMask = SecurityContext.Administrator.RegionMask; s.EnableFilter("RegionFilter").SetParameter("AdminRegionMask", regionMask); if (SecurityContext.Administrator.HavePermisions(PermissionType.ViewDrugstore) && SecurityContext.Administrator.HavePermisions(PermissionType.ViewSuppliers)) { return; } if (SecurityContext.Administrator.HavePermisions(PermissionType.ViewDrugstore)) { s.EnableFilter("DrugstoreOnlyFilter"); } if (SecurityContext.Administrator.HavePermisions(PermissionType.ViewSuppliers)) { s.EnableFilter("SupplierOnlyFilter"); } }); return(true); }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { var controllerBase = controller as ControllerBase; if (controllerBase == null) { throw new InvalidOperationException("The controller must derive from ControllerBase to use the AuthenticationFilter."); } var token = context.Session["token"] as Guid?; if (token.HasValue) { User user = ActiveRecordBase <User> .FindAllByProperty("Token", token).FirstOrDefault(); if (user != null) { controllerBase.CurrentUser = user; controllerBase.PropertyBag["currentUser"] = user; return(true); } } context.Flash["notice"] = "You have been logged out due to inactivity."; context.Response.Redirect("Sessions", "New"); return(false); }
/// <summary> /// Executes a sequence of steps to determine the browser location/culture. /// </summary> /// <param name="exec">When this filter is being invoked</param> /// <param name="context">Current context</param> /// <param name="controller">The controller instance</param> /// <param name="controllerContext">The controller context.</param> /// <returns> /// <c>true</c> if the action should be invoked, otherwise <c>false</c> /// </returns> public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { try { var localeId = GetLocaleId(context); if (localeId == null && setup.UseBrowser) { localeId = GetUserLanguage(context.Request); } if (localeId != null) { var culture = CultureInfo.CreateSpecificCulture(localeId); Thread.CurrentThread.CurrentCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; } } catch { if (setup.FailOnError) { throw; } } return(true); }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { if (context.Request.Headers["mybadheader"] != null) { context.Response.Write("Denied!"); return false; } return true; }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { context.CurrentUser = (LoggedInUser) context.Session["User"]; if (null == context.CurrentUser || !context.CurrentUser.Identity.IsAuthenticated ) { context.Response.Redirect("Login", "Index"); return false; } return true; }
/// <summary> /// Constructs a FilterAttribute associating /// the filter type and when the filter should be invoked. /// </summary> /// <param name="when">When to execute the filter</param> /// <param name="filterType">The filter implementation</param> public FilterAttribute(ExecuteWhen when, Type filterType) { if (!typeof(IFilter).IsAssignableFrom(filterType)) { throw new ArgumentException("The specified type does not implement IFilter"); } this.filterType = filterType; this.when = when; }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { if (context.Request.Headers["mybadheader"] != null) { context.Response.Write("Denied!"); return(false); } return(true); }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { if (context.CurrentUser == null || context.CurrentUser.Identity.IsAuthenticated == false) { context.Flash["error"] = "Du musst eingeloggt sein um den Mitglieder Bereich zu sehen"; context.Response.Redirect("", "home", "index"); return false; } return true; }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { if (controller is JelloScrumControllerBase) { JelloScrumControllerBase baseController = controller as JelloScrumControllerBase; baseController.PropertyBag.Add("titel", baseController.Titel); } return true; }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { var administrator = SecurityContext.Administrator; if (administrator == null) { context.Response.RedirectToUrl("~/Rescue/NotAuthorized.aspx"); return(false); } bool isPermissionGranted; if (_attribute.Required == Required.All) { isPermissionGranted = administrator.HavePermisions(_attribute.PermissionTypes); } else { isPermissionGranted = administrator.HaveAnyOfPermissions(_attribute.PermissionTypes); } if (!isPermissionGranted) { context.Response.RedirectToUrl("~/Rescue/NotAllowed.aspx"); return(false); } var mayBeActions = controllerContext.ControllerDescriptor.Actions[controllerContext.Action]; MethodInfo action; if (mayBeActions is ArrayList) { action = (MethodInfo)((ArrayList)mayBeActions)[0]; } else { action = (MethodInfo)mayBeActions; } if (action == null) { return(true); } if (!Permission.CheckPermissionByAttribute(administrator, action)) { context.Response.RedirectToUrl("~/Rescue/NotAllowed.aspx"); return(false); } return(true); }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { if (context.CurrentUser == null || context.CurrentUser.Identity.IsAuthenticated == false || (!(context.CurrentUser is Administrator))) { context.Flash["error"] = "Nur Administratoren haben Zugriff"; context.Response.Redirect("", "home", "index"); return false; } return true; }
/// <summary> /// Implementors should perform they filter logic and /// return <c>true</c> if the action should be processed. /// </summary> /// <param name="exec">When this filter is being invoked</param> /// <param name="context">Current context</param> /// <param name="controller">The controller instance</param> /// <param name="controllerContext">The controller context.</param> /// <returns> /// <c>true</c> if the action /// should be invoked, otherwise <c>false</c> /// </returns> public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { if (context.Request.Headers["HTTP_X_MOZ"].Equals("prefetch")) { Trace.Write("prefetch detected: sending 403 Forbidden"); context.Response.StatusCode = 403; return(false); } return(true); }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { if (context.Session.Contains("userSecurityPrincipal")) { System.Threading.Thread.CurrentPrincipal = context.Session["userSecurityPrincipal"] as Principal; return true; } context.Response.Redirect("session", "login", new Hashtable(){{"redirectUrl", context.Request.Url}}); return false; }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { try { throw exceptionFactory(); } finally { executed = true; } }
/// <summary> /// Implementors should perform they filter logic and /// return <c>true</c> if the action should be processed. /// </summary> /// <param name="exec">When this filter is being invoked</param> /// <param name="context">Current context</param> /// <param name="controller">The controller instance</param> /// <param name="controllerContext">The controller context.</param> /// <returns> /// <c>true</c> if the action /// should be invoked, otherwise <c>false</c> /// </returns> public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { if (context.Request.Headers["HTTP_X_MOZ"].Equals("prefetch")) { Trace.Write("prefetch detected: sending 403 Forbidden"); context.Response.StatusCode = 403; return false; } return true; }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { if (IsNotGet(context)) return true; if (controllerContext.LayoutNames == null || controllerContext.LayoutNames.Length == 0) return true; var layout = dictionaryAdapterFactory.GetAdapter<IDefaultLayout>(controllerContext.PropertyBag); layout.Departments = departmentsRepository.FindAll(); return true; }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { ArHelper.WithSession(s => { var regionMask = SecurityContext.Administrator.RegionMask; s.EnableFilter("RegionFilter").SetParameter("AdminRegionMask", regionMask); }); return(true); }
/// <summary> </summary> public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { controllerContext.PropertyBag["objectService"] = new objectService(); controllerContext.PropertyBag["scriptsService"] = new scriptsService(); controllerContext.PropertyBag["htmlService"] = new htmlService(); controllerContext.PropertyBag["settings"] = new settingsService(); controllerContext.PropertyBag["postingService"] = new postingService(); controllerContext.PropertyBag["themeService"] = new themeService(); controllerContext.PropertyBag["taxonomyService"] = new taxonomyService(); controllerContext.PropertyBag["userService"] = new userService(); Boolean loggedin = Controllers.BaseController.authenticated(); Boolean viewstate = false; if (Controllers.BaseController.authenticated()) { viewstate = userService.checkPrivleage("is_view_only"); } HttpCookie myCookie = Controllers.BaseController.context().Request.Cookies["hivviewonly"]; if (Controllers.BaseController.context().Request.Params["viewonly"] == "1") { viewstate = true; } if (myCookie != null) { viewstate = Convert.ToBoolean(myCookie.Value); } controllerContext.PropertyBag["viewonly"] = viewstate; controllerContext.PropertyBag["signedin"] = loggedin; //if(admin) if (siteService.is_admin()) { controllerContext.PropertyBag["versionService"] = new versionService(); controllerContext.PropertyBag["file_info"] = new file_info(); } /*site based. Must be installed first*/ if (Controllers.installController.is_installed()) { controllerContext.PropertyBag["current_site"] = siteService.getCurrentSite(); controllerContext.PropertyBag["siteService"] = new siteService(); controllerContext.PropertyBag["site_ext"] = Controllers.BaseController.site_ext; } return(true); }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { foreach (var key in ConfigurationManager.AppSettings.AllKeys) { controllerContext.PropertyBag[key] = ConfigurationManager.AppSettings[key]; } foreach (var s in Settings.AllKeys) { controllerContext.PropertyBag[s] = Settings.Get(s); } return(true); }
private void OnNewImage(object sender, Mat frame) { var bytes = frame.ToBytes(".png"); ChangeUI(() => { TheImage.Source = ImageHelper.ToImage(bytes); var attack = _customVisison.AnalyzeAsync(bytes).Result; WriteOutput(attack); ExecuteWhen.SameValueTwoTimes(attack, () => SpecialAttacks.Execute(attack)); }); }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { if (Settings.Get("build").Equals("release")) { var c = context.Response.ContentType; if (Compresstypes.Contains(c)) { context.UnderlyingContext.Response.Filter = context.Services.TransformFilterFactory.Create(typeof(WhitespaceTransformFilter), context.UnderlyingContext.Response.Filter) as Stream; } } return(true); }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { var isAjax = string.IsNullOrEmpty(context.Request.Headers["X-Requested-With"]) == false; if (isAjax) { ((SiteAwareController) controller).CancelLayout(); ((SiteAwareController) controller).IsAjax = true; } controllerContext.PropertyBag["IsAjax"] = isAjax; return true; }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { //IUser user = context.CurrentUser as IUser; //if (user != null) //{ Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("nl-NL"); //NOTE: Door een bug in castle zijn we genoodzaakt de culture te zetten om de juiste resourcemanager te krijgen //http://issues.castleproject.org/issue/MR-573 //Castle.MonoRail.Framework.Resources.DefaultResourceFactory.ResolveCulture(string), Castle.MonoRail.Framework Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture; //} return(true); }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { var user = session.Query<User>().FirstOrDefault(x => x.Name == context.CurrentUser.Identity.Name); if (!context.CurrentUser.Identity.IsAuthenticated || user == null) { context.Response.RedirectToUrl(string.Format("/signin?returnUrl={0}", context.Request.Url)); return false; } context.CurrentUser = user; controllerContext.PropertyBag["currentUser"] = user; return true; }
/// <summary> /// Called by Framework. /// </summary> /// <param name="exec">When this filter is being invoked. Must be BeforeAction</param> /// <param name="context">Current context</param> /// <param name="controller">The controller instance</param> /// <param name="controllerContext">The controller context.</param> /// <returns><c>true</c> Always</returns> public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { if (exec != ExecuteWhen.BeforeAction) { throw new ControllerException("MobileFilter can only be performed as a ExecuteWhen.BeforeAction"); } if (context.UnderlyingContext.Request.Browser.IsMobileDevice || context.UnderlyingContext.Request.UserAgent.Contains("Windows CE") || context.UnderlyingContext.Request.UserAgent.Contains("Smartphone")) { controllerContext.LayoutNames[0] = "mobile-" + controllerContext.LayoutNames[0]; controllerContext.PropertyBag["_IsMobileDevice"] = "True"; } return true; }
/// <summary> /// Implementors should perform they filter logic and /// return <c>true</c> if the action should be processed. /// </summary> /// <param name="exec">When this filter is being invoked</param> /// <param name="context">Current context</param> /// <param name="controller">The controller instance</param> /// <param name="controllerContext">The controller context.</param> /// <returns> /// <c>true</c> if the action /// should be invoked, otherwise <c>false</c> /// </returns> public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { if (exec == ExecuteWhen.AfterAction) { OnAfterAction(context, controller, controllerContext); return(true); } else if (exec == ExecuteWhen.AfterRendering) { OnAfterRendering(context, controller, controllerContext); return(true); } else // if (exec == ExecuteWhen.BeforeAction) { return(OnBeforeAction(context, controller, controllerContext)); } }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { if (!context.CurrentUser.Identity.IsAuthenticated) { //context.Response.Redirect("authentication", "index"); context.Response.RedirectToUrl(string.Format("/signin?returnUrl={0}", context.Request.Url)); return(false); } var user = session.Query <User>().FirstOrDefault(x => x.Name == context.CurrentUser.Identity.Name); context.CurrentUser = user; controllerContext.PropertyBag["currentUser"] = user; return(true); }
/// <summary> /// Implementors should perform they filter logic and /// return <c>true</c> if the action should be processed. /// </summary> /// <param name="exec">When this filter is being invoked</param> /// <param name="context">Current context</param> /// <param name="controller">The controller instance</param> /// <param name="controllerContext">The controller context.</param> /// <returns> /// <c>true</c> if the action /// should be invoked, otherwise <c>false</c> /// </returns> public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { try { context.Request.ValidateInput(); // Yeah compiler, this is an assignment object dummy = context.Request.Form; dummy = context.Request.QueryString; } catch(HttpRequestValidationException e) { context.Flash["validationError"] = context.Server.HtmlEncode(e.Message); } return true; }
/// <summary> /// Implementors should perform they filter logic and /// return <c>true</c> if the action should be processed. /// </summary> /// <param name="exec">When this filter is being invoked</param> /// <param name="context">Current context</param> /// <param name="controller">The controller instance</param> /// <param name="controllerContext">The controller context.</param> /// <returns> /// <c>true</c> if the action /// should be invoked, otherwise <c>false</c> /// </returns> public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { try { context.Request.ValidateInput(); // Yeah compiler, this is an assignment object dummy = context.Request.Form; dummy = context.Request.QueryString; } catch (HttpRequestValidationException e) { context.Flash["validationError"] = context.Server.HtmlEncode(e.Message); } return(true); }
/// <summary> /// Implementors should perform they filter logic and /// return <c>true</c> if the action should be processed. /// </summary> /// <param name="exec">When this filter is being invoked</param> /// <param name="context">Current context</param> /// <param name="controller">The controller instance</param> /// <param name="controllerContext">The controller context.</param> /// <returns> /// <c>true</c> if the action /// should be invoked, otherwise <c>false</c> /// </returns> public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { if (exec == ExecuteWhen.AfterAction) { OnAfterAction(context, controller, controllerContext); return true; } else if (exec == ExecuteWhen.AfterRendering) { OnAfterRendering(context, controller, controllerContext); return true; } else // if (exec == ExecuteWhen.BeforeAction) { return OnBeforeAction(context, controller, controllerContext); } }
internal async Task OnExecuteStartupTasks(ExecuteWhen when) { var ordered = StartupTasks .Where(t => t.ExecuteWhen == when) .OrderBy(t => t.ExecutionOrder) .ToArray(); if (ordered.Length == 0) { Log.Warn($"No startup tasks were found to execute during {when}."); } foreach (var task in ordered) { Log.Info($"Executing startup task {task.GetType().Name}."); await task.ExecuteAsync(null); } }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { controllerContext.PropertyBag["ViewName"] = Path.GetFileNameWithoutExtension(context.Request.Uri.Segments.Last()); controllerContext.PropertyBag["LocalPath"] = Path.GetFileNameWithoutExtension(context.Request.Uri.LocalPath); if (context.Session["AdminId"] != null) { ArHelper.WithSession(s => { context.Session["Admin"] = s.Get <Admin>(context.Session["AdminId"]); }); } controllerContext.PropertyBag["AccessEditLink"] = context.Session["Admin"] != null; controllerContext.PropertyBag["SiteAdress"] = context.ApplicationPath + "/"; return(true); }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { var sessionLanguage = (string)context.Session["LeTour-language"]; var defaultLanguage = CurrentSession.Query<Language>().FirstOrDefault(x => x.IsDefault); Language language = null; if (sessionLanguage != null) language = CurrentSession.Query<Language>().FirstOrDefault(x => x.ShortName == sessionLanguage); if (language == null) language = defaultLanguage; //NOTE: Door een bug in castle zijn we genoodzaakt de culture te zetten om de juiste resourcemanager te krijgen //http://issues.castleproject.org/issue/MR-573 //Castle.MonoRail.Framework.Resources.DefaultResourceFactory.ResolveCulture(string), Castle.MonoRail.Framework Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(language.Culture); Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture; return true; }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { var user = context.Session["Person"] as Person; if (user == null) { var uidInCookie = context.Request.ReadCookie("uid"); if (string.IsNullOrEmpty(uidInCookie) == false) { user = PeopleRepository.GetBy(new Guid(uidInCookie)); context.Session["Person"] = user; FormsAuthentication.SignOut(); FormsAuthentication.SetAuthenticationCookie(user.Username); } } if (user == null || MatchRequestedRole(user) == false) return RedirectToLoginPage(context); controllerContext.PropertyBag["Person"] = user; return true; }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { // Read previous authenticated principal from session // (could be from cookie although with more work) var user = (AuthenticatedUserDTO)context.Session["user"]; // Sets the principal as the current user context.CurrentUser = user; // Checks if it is OK if (context.CurrentUser == null || !context.CurrentUser.Identity.IsAuthenticated) { // Not authenticated, redirect to login context.Response.RedirectToSiteRoot(); // Prevent request from continue return false; } // Everything is ok return true; }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { var acceptEncoding = HttpContext.Current.Request.Headers["Accept-Encoding"]; if (string.IsNullOrEmpty(acceptEncoding)) { return(true); } if (acceptEncoding.Contains("gzip")) { context.Response.AppendHeader("Content-Encoding", "gzip"); context.UnderlyingContext.Response.Filter = new GZipStream(context.UnderlyingContext.Response.Filter, CompressionMode.Compress); } else if (acceptEncoding.Contains("deflate")) { context.Response.AppendHeader("Content-Encoding", "deflate"); context.UnderlyingContext.Response.Filter = new DeflateStream(context.UnderlyingContext.Response.Filter, CompressionMode.Compress); } return(true); }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { return(context.Session["Admin"] != null); }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { context.Response.Write("Hello World"); return true; }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { controllerContext.PropertyBag["scriptsService"] = scriptsService; return(true); }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { controllerContext.PropertyBag["version"] = Assembly.GetAssembly(controller.GetType()).GetName().Version.ToString(); return true; }
/// <summary> </summary> public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { //this should be removed if (!Controllers.BaseController.authenticated()) { System.Web.HttpContext.Current.Response.Redirect("~/center/login.castle"); } controllerContext.PropertyBag["post_types"] = ActiveRecordBase <posting_type> .FindAll(); controllerContext.PropertyBag["userService"] = userService; controllerContext.PropertyBag["helperService"] = helperService; controllerContext.PropertyBag["user"] = userService.getUserFull(); //return true; if (context.Request.IsLocal) { if (!controllerContext.Action.Contains("install") && ActiveRecordBase <appuser> .Exists()) { //controllerContext.PropertyBag["campuses"] = ActiveRecordBase<campus>.FindAll(); controllerContext.PropertyBag["post_types"] = ActiveRecordBase <posting_type> .FindAll(); controllerContext.PropertyBag["userService"] = userService; controllerContext.PropertyBag["helperService"] = helperService; controllerContext.PropertyBag["user"] = userService.getUserFull(); } return(true); } // Read previous authenticated principal from session // (could be from cookie although with more work) User user = (User)context.Session["user"]; // Redirect to dailystellar.wsu.edu because dailystellar.com can't catch the cookie //if (context.Request.Uri.ToString().ToLower().Contains("dailystellar.com")) //{ // context.Response.Redirect("http://dev.stellar.wsu.edu/admin"); // return false; //} // Sets the principal as the current user context.CurrentUser = user; if (Controllers.BaseController.authenticated()) { return(true); } // Checks if it is OK //if (context.CurrentUser == null || // !context.CurrentUser.Identity.IsAuthenticated || // !Authentication.logged_in()) if (Controllers.BaseController.authenticated()) { // Not authenticated, redirect to login String username = userService.getNid(); appuser[] users = ActiveRecordBase <appuser> .FindAllByProperty("nid", username); if (users.Length == 0) { //context.Response.RedirectToUrl("~/admin", false); //return false; } //context.Session["manager"] = true; //context.Cookies["unldap"].Value = username; user = new User(username, new String[0]); context.CurrentUser = user; System.Threading.Thread.CurrentPrincipal = user; } if (userService.isLogedIn())// || Authentication.logged_in()) /* not 100% we can't just strip off the Authentication.*/ { appuser currentUser = userService.getUser(); if (currentUser != null) { appuser you = ActiveRecordBase <appuser> .Find(currentUser.baseid); you.logedin = true; you.last_active = DateTime.Now; ActiveRecordMediator <appuser> .Update(you); ActiveRecordMediator <appuser> .Save(you); } } if (!controllerContext.Action.Contains("install")) { // controllerContext.PropertyBag["campuses"] = ActiveRecordBase<campus>.FindAll(); controllerContext.PropertyBag["post_types"] = ActiveRecordBase <posting_type> .FindAll(); controllerContext.PropertyBag["userService"] = userService; controllerContext.PropertyBag["helperService"] = helperService; controllerContext.PropertyBag["user"] = userService.getUserFull(); } // Everything is ok return(true); }
/// <summary> /// Executes a sequence of steps to determine the browser location/culture. /// </summary> /// <param name="exec">When this filter is being invoked</param> /// <param name="context">Current context</param> /// <param name="controller">The controller instance</param> /// <param name="controllerContext">The controller context.</param> /// <returns> /// <c>true</c> if the action should be invoked, otherwise <c>false</c> /// </returns> public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { try { var localeId = GetLocaleId(context); if (localeId == null && setup.UseBrowser) localeId = GetUserLanguage(context.Request); if (localeId != null) { var culture = CultureInfo.CreateSpecificCulture(localeId); Thread.CurrentThread.CurrentCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; } } catch { if (setup.FailOnError) throw; } return true; }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { context.Response.Write("Hello World"); return(true); }
protected virtual bool ProcessFilters(IExecutableAction action, ExecuteWhen when) { foreach(var desc in filters.Union(GetActionLevelFilters(action))) { if (action.ShouldSkipFilter(desc.FilterType)) { continue; } if ((desc.When & when) != 0) { if (!ProcessFilter(when, desc)) { return false; } } } return true; }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { return(false); }
private bool ProcessFilter(ExecuteWhen when, FilterDescriptor desc) { if (desc.FilterInstance == null) { desc.FilterInstance = filterFactory.Create(desc.FilterType); IFilterAttributeAware filterAttAware = desc.FilterInstance as IFilterAttributeAware; if (filterAttAware != null) { filterAttAware.Filter = desc.Attribute; } } try { if (logger.IsDebugEnabled) { logger.DebugFormat("Running filter {0}/{1}", when, desc.FilterType.FullName); } return desc.FilterInstance.Perform(when, engineContext, this, context); } catch(Exception ex) { if (logger.IsErrorEnabled) { logger.Error("Error processing filter " + desc.FilterType.FullName, ex); } throw; } }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { controllerContext.PropertyBag["version"] = Assembly.GetAssembly(controller.GetType()).GetName().Version.ToString(); return(true); }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { context.Trace.Write(exec.ToString()); return(true); }
private bool ProcessFilters(IExecutableAction action, ExecuteWhen when) { foreach(FilterDescriptor desc in filters) { if (action.ShouldSkipFilter(desc.FilterType)) { continue; } if ((desc.When & when) != 0) { if (!ProcessFilter(when, desc)) { return false; } } } return true; }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { var user = currentSession.Query<User>().FirstOrDefault(x => x.Name == context.CurrentUser.Identity.Name); return user != null && user.IsActive; }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { return false; }
public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext) { controllerContext.PropertyBag["categories"] = ActiveRecordBase <categories> .FindAll(); controllerContext.PropertyBag["campuses"] = ActiveRecordBase <campus> .FindAll(); controllerContext.PropertyBag["colleges"] = ActiveRecordBase <colleges> .FindAll(); controllerContext.PropertyBag["departments"] = ActiveRecordBase <departments> .FindAll(); controllerContext.PropertyBag["admindepartments"] = ActiveRecordBase <admindepartments> .FindAll(); controllerContext.PropertyBag["programs"] = ActiveRecordBase <programs> .FindAll(); controllerContext.PropertyBag["schools"] = ActiveRecordBase <schools> .FindAll(); controllerContext.PropertyBag["userService"] = userService; controllerContext.PropertyBag["helperService"] = helperService; controllerContext.PropertyBag["helper"] = helperService; if (context.Request.IsLocal) { users currentUser = userService.getUserFull(); if (currentUser != null) { users you = ActiveRecordBase <users> .Find(currentUser.id); you.loggedin = true; you.LastActive = DateTime.Now; ActiveRecordMediator <users> .Update(you); ActiveRecordMediator <users> .Save(you); } //return true; } else { // Read previous authenticated principal from session // (could be from cookie although with more work) User user = (User)context.Session["user"]; // Sets the principal as the current user context.CurrentUser = user; String username = Authentication.authenticate(); users[] authors = ActiveRecordBase <users> .FindAllByProperty("nid", username); if (authors.Length == 0) { context.Response.RedirectToUrl("~/?username="******"manager"] = true; context.Session["username"] = username; user = new User(username, new String[0]); context.CurrentUser = user; System.Threading.Thread.CurrentPrincipal = user; if (userService.isLoggedIn()) { users currentUser = userService.getUserFull(); if (currentUser != null) { users you = ActiveRecordBase <users> .Find(currentUser.id); you.loggedin = true; you.LastActive = DateTime.Now; ActiveRecordMediator <users> .Update(you); ActiveRecordMediator <users> .Save(you); } } } controllerContext.PropertyBag["campus"] = userService.getUserCoreCampus(); // Everything is ok return(true); }