I wouldn't wrap the views within the event-filter.
There are a few things you can do to figure out where it's going wrong.

In you xml config  you can add logging as a property, which will tell you what's happening during the event life cycle. Add:
<property name="Logging" type="MachII.logging.LoggingProperty" />

This is kind of like CF debugging.

More common and it will tell you exactly what's going on in the filter is to add

<cfdump var=""/><cfabort/>

at certain steps in the filter. If the filter is not running you'll know right away. I would cfdump your role_id and the boolean return value to debug it.
Do you have a sysadmin.accessDenied event defined? From your original post I did not see that in the config?


geomunir wrote:
I made the changes, however, it does not seems to be working. First of
all, i dont see permissionValidation.cfc initiated at all. If its not
initiating, then sysadmin.accessDenied wont be announced.

If i change to something like this, then it does:
<event-handler event="sysadmin.server_setting" access="public">
	<event-filter name="permissionValidation">
		<parameter name="role_id" value="3" />
		<view-page name="sysadmin.act_server_setting"/>
		<view-page name="sysadmin.server_setting"
contentArg="layout.content" />
		<execute subroutine="sysadmin.compileLayout" />
	</event-filter>
</event-handler>


But, after the change, nothing happens. Blank page is shown.


Mike,
role_id does change, from event to event.



On Dec 16, 12:18 am, "Peter J. Farrell" <[email protected]> wrote:
  
ParamArgs (nested inside your filter when you declare it in an
event-handler) are passed.  Change:

if(isUserInRole(event.getArg(role_id)))

to

if(isUserInRole(arguments.paramArgs.role_id))

I'd also clear the event-queue before annnouncing your access denied event:

arguments.eventContext.clearEventQueue():

Also, you can change this:

arguments.eventContext.announceEvent("sysadmin.accessDenied",

to this:

announceEvent("sysadmin.accessDenied", arguments.event.getArgs());

AnnounceEvent() is one of the built in methods in the BaseComponent
class that MachII.framework.EventFilter inherits from.

HTH,
.Peter

geomunir said the following on 12/16/2009 01:36 AM:





    
I'm trying to get filter working, but for some reason its not working
as expected. Maybe, something in my logic or i'm not getting the
filter right.
      
Whats happening?: Well, I see the event filter is being triggered, but
nothing happens, regular page is displayed. I'm logged in as not
authorized user (role_id=4), and reguired role_id = 3 (parameter).
      
When i'm not authorized, i should be redirected to
sysadmin.accessDenied event.
      
Here is the code:
      
mach-ii.xml
--
   <event-filters>
           <event-filter name="permissionValidation"
type="blaz.filters.permissionValidation" />
   </event-filters>
      
   <event-handler event="sysadmin.server_setting" access="public">
           <event-filter name="permissionValidation">
                   <parameter name="role_id" value="3" />
           </event-filter>
      
           <view-page name="sysadmin.act_server_setting"/>
           <view-page name="sysadmin.server_setting"
contentArg="layout.content" />
           <execute subroutine="sysadmin.compileLayout" />
      
   </event-handler>
      
permissionValidation.cfc
<cfcomponent extends="MachII.framework.EventFilter" hint="Permision
Validation">
    <cffunction name="configure" access="public" output="false"
returntype="void" hint="Configures the filter">
           <!--- Does nothing --->
    </cffunction>
      
   <!--- Authenticate Specfic Role  --->
    <cffunction name="filterEvent" returntype="boolean">
           <!--- Required Arguments --->
        <cfargument name="event" type="MachII.framework.Event"
required="true" />
        <cfargument name="eventContext"
type="MachII.framework.EventContext" required="true" />
        <cfargument name="paramArgs" type="struct" required="false"
default="#StructNew()#" />
      
        <cfscript>
                   //Declare variable and assign initial value
                   var validationBoolean = false;
      
                   //If logged in user matches with Required role
                   if(isUserInRole(event.getArg(role_id)))
                   {
                           //Assign value to a variable
                           validationBoolean = true;
                   }
                   else
                   {
                           //Assign value to a variable
                           validationBoolean = false;
      
                           //Announce Mach-II Event-Handler
                           arguments.eventContext.announceEvent("sysadmin.accessDenied",
arguments.event.getArgs());
                   }
      
           </cfscript>
      
           <cfreturn validationBoolean>
    </cffunction>
      
</cfcomponent>
      
--

The Harmonious Programmer
<http://feeds.feedburner.com/%7Er/TheHarmoniousProgrammer/%7E6/1>

*Peter J. Farrell*
Email: [email protected] | p...@maestropublishing
Blog: The Harmonious Programmer <http://blog.maestropublishing.com>
Twitter/Identi.ca: @maestrofjp

 TheHarmoniousProgrammer.1.gif
64KViewDownload- Hide quoted text -

- Show quoted text -
    

  

--
You received this message because you are subscribed to Mach-II for CFML list.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/mach-ii-for-coldfusion?hl=en
SVN: http://greatbiztoolsllc.svn.cvsdude.com/mach-ii/
Wiki / Documentation / Tickets: http://greatbiztoolsllc.trac.cvsdude.com/mach-ii/

Reply via email to