OOP... yes, this was my first component, so there's much that can
be reworked.  All templates in use are under the same application.cfc.
It's the same set up that's working on my dev pc...

I tried your idea about putting the necessary data into the result set
coming from the method, but I couldn't seem to get the data in there.

I'm returning the data in "managerStruct" for the purposes of logging in.
The other data just sets permissions for the user.

Here's the CFC I'm using.  Do you see any issues?  How would I change it
to include the permissions in the struct? One thing that may be complicating
this is how this method is being called from another template called
"login_processor.cfm" . I didn't write this originally, just modified it, so
I'm not entirely sure of how it works.  Here's the code in that one.

You can try this setup out at http://sitemanager.fortstewart.com and use
these credentials to login:  email:  [email protected]  password:  guest

If the login worked properly, you should be the menu on the page change
to include about 15 items.  But online, unlike on my dev pc, the menu doesn't 
change.
(And you can see from the cfdump of session variables that none of the 
perimissions
are included.

Suggestions?  Thanks, Rick

login_processor.cfm 
-------------------------------------------------------------------------

        <cfset mdata = createObject("component","manager_data")>
        <cfset thedata = mdata.getmanagerData(form.email_address, 
form.password)>
        <cfset ojson = createObject("component","cfjson")>
        <cfset results = ojson.encode(thedata)>

        <cfoutput>#results#</cfoutput>


manager_data.cfc 
-----------------------------------------------------------------------------

<cfcomponent displayname="manager_data" hint="Contains manager database query" 
output="false">

        <cffunction name = "getmanagerData">
        
                <cfargument name = "email_address"      type="string" 
required="yes">
                <cfargument name = "password"           type="string" 
required="yes">
                
                <cfquery name="get_manager" datasource="#application.dsn#">
                
                        select          manager_id, email_address, password, 
announcements,
res_announcements, rental_properties,
                                        new_communities, agents, 
featured_properties, open_houses,
local_websites, fort_stewart,
                                        our_community, approved_cities, 
site_managers
                                                
                        from            site_managers
                        where           email_address = 
'#arguments.email_address#'
                        and             password = '#arguments.password#'
                        
                </cfquery>
                
                <cfset managerStruct = structNew()>
                
                <cfif get_manager.recordcount gt 0>
                
                        <cfset session.manager_id = get_manager.manager_id>
                        <cfset session.announcements = 
get_manager.announcements>
                        <cfset session.res_announcements = 
get_manager.res_announcements>
                        <cfset session.rental_properties = 
get_manager.rental_properties>
                        <cfset session.new_communities = 
get_manager.new_communities>
                        <cfset session.agents = get_manager.agents>
                        <cfset session.featured_properties = 
get_manager.featured_properties>
                        <cfset session.open_houses = get_manager.open_houses>
                        <cfset session.local_websites = 
get_manager.local_websites>
                        <cfset session.fort_stewart = get_manager.fort_stewart>
                        <cfset session.our_community = 
get_manager.our_community>
                        <cfset session.approved_cities = 
get_manager.approved_cities>
                        <cfset session.site_managers = 
get_manager.site_managers>
                        
                        <cfset managerStruct.login = "Login Successful">
                
                <cfelse>

                        <cfif not len(trim(arguments.email_address))>
                                <cfset managerStruct.emailerror = "Please enter 
your email address">
                        </cfif>
                        
                        <cfif not len(trim(arguments.password))>
                                <cfset managerStruct.passworderror = "Please 
enter your password">
                        </cfif>
                        
                        <cfset managerStruct.login = "Login Unsuccessful">
                        
                </cfif>
                
                <cfreturn managerStruct />
                
        </cffunction>

</cfcomponent>

> -----Original Message-----
> From: Ian Skinner [mailto:[email protected]]
> Sent: Wednesday, January 07, 2009 9:44 AM
> To: cf-talk
> Subject: Re: Is this acceptable or reasonable CFC usage?
> 
> Rick Faircloth wrote:
> > I'm trying to set session variables for login with the code below.
> > It works fine on my local dev pc, but on the production server,
> > no session variables are being set.  Is the code below not appropriate?
> >
> > Thanks,
> >
> > Rick
> 
> ColdFusion does not care, but lots of OOP types will probably point out
> that it is considered bad practice to reference external scopes inside
> of a component.  Just for this type of difficulty.
> 
> ColdFusion's only problem with this is the for sessions to work properly
> all code referencing the same session must be in the same 'application'
> as determined with an <cfapplication...> tags with the same 'name'
> property.  How this affects components is that they are often placed in
> directories outside the normal web directories and thus are not under
> the usual Application.cfm|.cfc file that defines that application name.
> This is easy to fix by making sure that somehow or the other the
> component runs an <cfapplication....> tag with the desired application
> name.  But this can become very complex very quickly if the coponent is
> meant to be used by different applications running on the system.
> 
> Thus we are back to the OOP best practice of not referencing external
> scopes to the the component.  The better idea would be to return a
> structure of the data you are planning on putting into the session
> scope.  Then the calling code, that presumably is part of the
> appropriate 'application' will receive this structure and can simply
> copy it into the session scope.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317521
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to