Howdy all - 

So I thought I had this login thing worked out, but after an hour of pulling 
out my hair I'm stumped.

In short, I can fill out the login form and submit it. It checks the DB just 
fine and CF logs you in just fine. It's when you reach the bottom of the 
act_login.cfm template it fails when the CFLOCATION sends you back where you 
came from.

Here's the code out line.


Code included for: Application.cfc and act_Login.cfm

 (notes for app flow are in *****NOTES**** in the code)

First I'll show the Application.cfc so you can see how that's set up. In short 
it sets you up as a guest that is a record in the db if you are not logged in. 
(for foriegn key needs.) No matter what I try, when the CFLOCATION tag fires in 
the act_Login.cfm template, the <cfquery name="GetNoAuthGuest" in the 
application.cfc fires. Thus that means <cfif GetAuthUser() eq ""> above the 
query is evaluating to true. ie: login data was lost in the CFLOCATION.

In the act_login.cfm file it just takes your data and logs you in or fails. The 
DESTINATION var is passed in from where you came from as a URL so you can get 
back there. ie: DESTINATION = "http://www.r00t.com/FileShare/index.cfm";

Also, the queries have been obscured.

Thank you to everyone who can give a minute to look this over, I hope I did a 
decent job at giving everthing you need to review.

----------------------------------------------------------
----------------------------------------------------------

Application.cfc - (brief)
----------------------------------------------------------
<cfset this.name="ThisIntranet">
<cfset this.sessionmanagement="yes">
<cfset this.SetClientCookies="no">
<cfset this.loginstorage="session">
<cfset this.applicationTimeout=CreateTimeSpan(0,12,0,0)>
<cfset this.sessionTimeout=CreateTimeSpan(0,4,0,0)>

<cffunction name="onSessionStart" returntype="void">

        <cfif GetAuthUser() eq "">
                <!--- if no user info is passed from IE's ActiveDirectory 
connect --->
                <cfif cgi.AUTH_USER eq "">
                        <!--- log user in as guest---> 
                        <!--- get guest account --->

****************RUNS AS IT SHOULD THE FIRST TIME, BUT RUNS THIS EVEN AFTER 
LOGIN (CFLOCATION relocation in act_login.cfm) ***********************

                        <cfquery name="GetNoAuthGuest" 
dataSource="#request.DATASOURCE#">
                                SELECT DATA
                                FROM TABLE
                                WHERE UPPER(E.LAST_NAME) = 'CFL GUEST'
                        </cfquery>
                        <cflogin>
                                <cfloginuser name="#GetNoAuthGuest.DATA#" 
Password="cfl-guest" roles="GUEST">
                        </cflogin>
                <cfelse>
                        <!--- if user info is passed from IE's ActiveDirectory 
connect --->
                        <CFSET AUTH_USER = 
ListLast(Replace(Replace(UCASE(cgi.AUTH_USER),"\",",","ALL"),"/",",","ALL"))>
                        
                        <cfquery name="loginQuery" 
dataSource="#request.DATASOURCE#">
                                SELECT DATA
                                FROM TABLE
                                WHERE USER_NAME = '#AUTH_USER#'
                        </cfquery>
                        
                        <cfif loginQuery.RecordCount neq 0>
                                <cflogin>
                                        <cfloginuser name="#loginQuery.DATA#" 
Password="#loginQuery.password#" roles="#loginQuery.ROLE#">
                                </cflogin>
                        <cfelse>
                                <!--- log user in as guest---> 
                                <!--- get guest account --->
                                <cfquery name="GetGuest" 
dataSource="#request.DATASOURCE#">
                                        SELECT DATA
                                        FROM TABLE
                                        WHERE UPPER(E.LAST_NAME) = 'CFL GUEST'
                                </cfquery>
                                <cflogin>
                                        <cfloginuser name="#GetGuest.DATA#" 
Password="cfl-guest" roles="GUEST">
                                </cflogin>
                        </cfif>
                </cfif>
        </cfif>

</cffunction>
--------------------------------------------------------------------
--------------------------------------------------------------------

act_Login.cfm - 
--------------------------------------------------------------------
<cfparam name="destination" default="">
  
<cfif J_USERNAME IS "" OR J_PASSWORD IS "">
        <cfoutput>
           <h2>You must enter text in both the User Name and Password 
fields.</h2>
        </cfoutput>
        <cfinclude template="dsp_LoginForm.cfm">
        <cfabort>

<cfelse>

        <cfquery name="loginQuery" dataSource="#request.DATASOURCE#">
                SELECT DATA
                FROM TABLE
                WHERE USER = '#J_USERNAME#'
                        AND PASSWORD = '#J_PASSWORD#'
        </cfquery>

        <cfif loginQuery.RecordCount neq 0>
                <cflogout>
                <cflogin applicationtoken="#application.applicationname#">
                        <cfloginuser name="#loginQuery.DATA#" Password = 
"#loginQuery.PASSWORD#" roles="#loginQuery.ROLE#">
                </cflogin>      
        <cfelse>
                <cfoutput>
                        <H2>Your login information is not valid.<br>Please Try 
again</H2>
                </cfoutput>   
                <cfinclude template="dsp_LoginForm.cfm">
                <cfabort>
        </cfif>

</cfif>  

<cfif destination neq "">
************THIS IS WHERE IT FAILS TO PASS THE LOGIN INFO ?? 
***********************
        <cflocation url="#destination#" addtoken="Yes">
<cfelse>
        <cflocation url="index.cfm" addtoken="Yes">
</cfif>
-------------------------------------------------------------------------------

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:263191
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