Makes sense, so instead of broadcasting authenticate at during the
admin.login event I should create a new event handler?

On Dec 7, 2:38 pm, "Sean Corfield" <[EMAIL PROTECTED]> wrote:
> Looks like you're broadcasting the message at the start of displaying
> the form. You need an event handler for the form submission and that's
> where you authenticate.
>
> On Sat, Dec 6, 2008 at 10:58 AM, Dan Vega <[EMAIL PROTECTED]> wrote:
>
> > I am playing around with the new event-types and I am sure I am doing
> > something wrong but I can't figure out what it is. I have an app with
> > an admin area. The admin area is secure and you need to be logged in
> > to access it, if your not we show a login form, nothing fancy here.
>
> >    <event-type name="securedPage">
> >        <before>
> >            <broadcasts>
> >                <message name="isAuthenticated"/>
> >            </broadcasts>
> >            <results>
> >                <result name="notAuthenticated" do="admin.login"/>
> >            </results>
> >        </before>
> >    </event-type>
>
> >    <event-type name="adminTemplate">
> >        <before>
> >            <results>
> >                <result do="template.admin" />
> >            </results>
> >        </before>
> >    </event-type>
>
> > And here are my event handlers cut down for my admin section. This to
> > me is saying everytime one of these events are requested I am going to
> > broadcast the isAuthenticated() message and also use my admin template
> > wrapper. If I am not authenticated I route logic to my admin.login
> > which is nothing more then a simple form.
>
> >    <event-handler name="admin.home" type="securedPage,adminTemplate">
> >                <views>
> >                        <include name="body" template="admin/index.cfm" />
> >                </views>
> >    </event-handler>
> >    <event-handler name="admin.categories"
> > type="securedPage,adminTemplate">
> >                <views>
> >                        <include name="body" template="admin/categories.cfm" 
> > />
> >                </views>
> >    </event-handler>
> >    <event-handler name="admin.category"
> > type="securedPage,adminTemplate">
> >                <views>
> >                        <include name="body" template="admin/category.cfm" />
> >                </views>
> >    </event-handler>
>
> >    <event-handler name="admin.login" type="adminTemplate">
> >                <broadcasts>
> >            <message name="authenticate"/>
> >        </broadcasts>
> >        <views>
> >                        <include name="body" template="admin/login.cfm" />
> >                </views>
> >        </event-handler>
>
> > This works great but now have presented the user with a form and I
> > need them to login. You will notice on my admin.login I now broadcast
> > an authenticate message. Here is my security controller.
>
> >        <controller id="SecurityController"
> > type="thetiestore.controller.SecurityController">
> >        <message-listener message="authenticate"
> > function="authenticate"/>
> >        <message-listener message="isAuthenticated"
> > function="isAuthenticated"/>
> >        </controller>
>
> > And the controller itself - I have no idea why but the username and
> > password values from the form are not in the event when I request
> > them.
>
> > <cfcomponent extends="ModelGlue.gesture.controller.Controller"
> > output="false">
>
> >        <cffunction name="init" access="public" output="false"
> > hint="Constructor">
> >                <cfreturn this />
> >        </cffunction>
>
> >        <cffunction name="authenticate" access="public" returnType="void"
> > output="true">
> >                <cfargument name="event" type="ModelGlue.Core.Event"
> > required="true">
> >                <cfset var username = arguments.event.getValue("username")>
> >                <cfset var password = arguments.event.getValue("password")>
>
> >                <cfif username EQ "dan" AND password EQ "password">
> >                        <cfset session.adminLoggedIn = true />
> >                </cfif>
>
> >                <cfset arguments.event.addResult("username",username)>
> >                <cfset arguments.event.addResult("password",password)>
>
> >        </cffunction>
>
> >        <cffunction name="isAuthenticated" access="public" returnType="void"
> > output="false">
> >                <cfargument name="event" type="ModelGlue.Core.Event"
> > required="true">
>
> >                <cfif not structKeyExists(session, "adminloggedin") OR NOT
> > session.adminLoggedIn>
> >                        <cfset arguments.event.addResult("notAuthenticated")>
> >                </cfif>
> >        </cffunction>
>
> > </cfcomponent>
>
> > I am still a mg newb so I apologize if I am missing something simple
> > here.
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "model-glue" group.
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/model-glue?hl=en

For more about Model-Glue, check http://www.model-glue.com .
-~----------~----~----~----~------~----~------~--~---

Reply via email to