I'm going to start working on the next planned update to
TrafficMunkey, which will have much better handling of user
permissions. The plan is that instead of throwing a Missing Include
error when the page exists but is hidden because of user permissions,
instead TrafficMunkey will traverse up the site tree, until it finds a
parent site for which the user does have permissions, and then serve
up the default page for that site for the user's roles (or lack of
roles in the case of a session logout).
In the meantime, the work-around is to put a cftry/cfcatch block
around the site definition tags and catch an error of type
"TrafficMunkey.MissingLink". In there you'll do a cflocation to
Request.TrafficMunkey.get('baseURLPath') & "index.cfm".
<cftry>
<site title="MySite" template="template.cfm" disableCaching="true"
handleMissingInclude="false">
<page title="Login" template="login.cfm" roles="false">
<cfparam name="Session.lastURL" default="" />
<link name="success" url="#Session.lastURL#" />
</page>
<site title="User Management" roles="true">
...
</site>
<page title="Logout" template="logout.cfm" roles="true">
<link name="success" url="" />
</page>
</site>
<cfcatch type="TrafficMunkey.MissingLink">
<!--- Always throw error during debugging.
<cfrethrow> --->
<cfif Arguments.targetPage neq
Request.TrafficMunkey.get('baseURLPath')&"index.cfm">
<!--- If their login has expired, save the request page, so we
can return after authentication. --->
<cfif ListLast(CGI.SCRIPT_NAME,"/") neq "login.cfm">
<cfset Session.lastURL = CGI.SCRIPT_NAME & "?" &
CGI.QUERY_STRING />
</cfif>
<!--- If their login has expired, return to the base URL. --->
<cflocation url="index.cfm" addtoken="no">
<cfelse>
<cfrethrow>
</cfif>
</cfcatch>
</cftry>
While debugging, though, you'll want to always do a <cfrethrow>
instead, in case there are any true MissingLink errors, like
forgetting a <link> tag with a <page> tag, or linking to a page that
doesn't exist in your site map yet.
<cfcatch type="TrafficMunkey.MissingLink">
<!--- Always throw error during debugging. --->
<cfrethrow>
<cfif Arguments.targetPage neq
Request.TrafficMunkey.get('baseURLPath')&"index.cfm">
<!--- If their login has expired, save the request page, so we
can return after authentication. --->
<cfif ListLast(CGI.SCRIPT_NAME,"/") neq "login.cfm">
<cfset Session.lastURL = CGI.SCRIPT_NAME & "?" &
CGI.QUERY_STRING />
</cfif>
<!--- If their login has expired, return to the base URL. --->
<cflocation url="index.cfm" addtoken="no">
<cfelse>
<cfrethrow>
</cfif>
</cfcatch>
Pete