mahpog
asked on
OnRequestStart - Security Sign on and Request Page Setup together
I have made use of the Application.cfc and the OnRequestStart to require a security signon. I have a new application that uses the OnRequestStart to setup the Request argument for each page processes.
I need to add the security feature but I do not know how to get both to work under OnRequestStart. I tried to copy one with the other and got error saying "missing /cffunction" . I also tried naming one as "OnRequestStart" and the other as "OnRequest" Result: I either get the secuirty screen working but it will no longer go to the index.cfm page. Or I get to my index.cfm without a needed security signon.
How do I get both to work>>>??????
Here is my code:
<cfcomponent
output="false"
hint="Handles the application-level event handlers and application settings.">
<!--- Define application settings. --->
<cfset THIS.Name = "events" />
<cfset THIS.sessionmanagement="Ye s">
<cfset THIS.clientmanagement="Yes ">
<cfset THIS.setclientcookies="Yes ">
<cfset THIS.loginstorage="session ">
<cfset THIS.sessiontimeout="#crea tetimespan (0,1,0,0)# ">
<cfset THIS.applicationtimeout="# createtime span(0,4,0 ,0)#">
<cfset REQUEST.Source = "RQITest" />
<!--- Define page request settings. --->
<cfsetting
showdebugoutput="true"
requesttimeout="20"
/>
<cffunction name="onApplicationStart" returnType="boolean" output="false">
<!--- When did the application start? --->
<cfset APPLICATION.appStarted = now()>
<cfreturn true>
</cffunction>
<cffunction name="onApplicationEnd" returnType="void" output="false">
<cfargument name="appScope" required="true">
<!--- Log how many minutes the application stayed alive --->
<cflog file="#THIS.name#" text=
"App ended after #dateDiff('n',ARGUMENTS.ap pScope.app Started,no w())# minutes.">
</cffunction>
<cffunction
name="OnRequest">
<!--- If user is not logged in, force them to now --->
<cfif NOT IsDefined("Session.Auth.Is loggedIn") >
<!--- If the user is now submitting "login" form, include Login Check" code to validate user --->
<cfif IsDefined("Form.UserLogin" )>
<cfinclude template="home/LoginCheck. cfm">
</cfif>
<cfinclude template="home/Login.cfm">
<cfabort>
</cfif>
</cffunction>
<cffunction
name="OnRequestStart"
access="public"
returntype="boolean"
output="false"
hint="Fires the initial pre-page processing event.">
<!--- Define arguments. --->
<cfargument
name="Page"
type="string"
required="true"
hint="The ColdFusion script who's execution has been requested."
/>
<cfset REQUEST.DSN = StructNew() />
<cfset REQUEST.DSN.Source = "RQITest" />
<cfreturn true />
</cffunction>
</cfcomponent>
I need to add the security feature but I do not know how to get both to work under OnRequestStart. I tried to copy one with the other and got error saying "missing /cffunction" . I also tried naming one as "OnRequestStart" and the other as "OnRequest" Result: I either get the secuirty screen working but it will no longer go to the index.cfm page. Or I get to my index.cfm without a needed security signon.
How do I get both to work>>>??????
Here is my code:
<cfcomponent
output="false"
hint="Handles the application-level event handlers and application settings.">
<!--- Define application settings. --->
<cfset THIS.Name = "events" />
<cfset THIS.sessionmanagement="Ye
<cfset THIS.clientmanagement="Yes
<cfset THIS.setclientcookies="Yes
<cfset THIS.loginstorage="session
<cfset THIS.sessiontimeout="#crea
<cfset THIS.applicationtimeout="#
<cfset REQUEST.Source = "RQITest" />
<!--- Define page request settings. --->
<cfsetting
showdebugoutput="true"
requesttimeout="20"
/>
<cffunction name="onApplicationStart" returnType="boolean" output="false">
<!--- When did the application start? --->
<cfset APPLICATION.appStarted = now()>
<cfreturn true>
</cffunction>
<cffunction name="onApplicationEnd" returnType="void" output="false">
<cfargument name="appScope" required="true">
<!--- Log how many minutes the application stayed alive --->
<cflog file="#THIS.name#" text=
"App ended after #dateDiff('n',ARGUMENTS.ap
</cffunction>
<cffunction
name="OnRequest">
<!--- If user is not logged in, force them to now --->
<cfif NOT IsDefined("Session.Auth.Is
<!--- If the user is now submitting "login" form, include Login Check" code to validate user --->
<cfif IsDefined("Form.UserLogin"
<cfinclude template="home/LoginCheck.
</cfif>
<cfinclude template="home/Login.cfm">
<cfabort>
</cfif>
</cffunction>
<cffunction
name="OnRequestStart"
access="public"
returntype="boolean"
output="false"
hint="Fires the initial pre-page processing event.">
<!--- Define arguments. --->
<cfargument
name="Page"
type="string"
required="true"
hint="The ColdFusion script who's execution has been requested."
/>
<cfset REQUEST.DSN = StructNew() />
<cfset REQUEST.DSN.Source = "RQITest" />
<cfreturn true />
</cffunction>
</cfcomponent>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER