I have login in my new application that checks on each request if user is logged in. If user is not logged in automatically will be redirected to the login page. I have situation where user clicks on Forgot Password
. In that case I generated temporary link that will direct user to reset.cfm
page. However problem is that user is not logged in and if I try to click on the link that should direct me to reset.cfm
my code will direct me instead to login.cfm
. Here is logic that I use in Application.cfc
:
public boolean function onRequestStart(required string thePage) output="false" {
local.page = listLast(arguments.thePage,"/");
//onApplicationStart();
if(!listFindNoCase("Login.cfm,Authentication.cfc",page)){
if(structKeyExists(SESSION, "loggedin") AND SESSION.loggedin EQ false){
location(url="https://example.com", addToken="false");
}
}
return true;
}
As you can see in the example above, on each request I check the flag loggedin
. I'm wondering how I can let the user access Reset.cfm?token=94129873129
link to the page? I would like to keep my logic to work the same for the users that are not logged in. At the same time I need to give them an access to Reset.cfm
. If anyone have suggestions how this can be achieved or better way to handle this please let me know. One solution that I was thinking about was this solution, in Main.cfm
:
<cfif structKeyExists(url,"token")>
<cfinclude template="Reset.cfm">
<cfelse>
<cfinclude template="Login.cfm">
</cfif>
If url parameter token
exists then direct user to Reset.cfm
if not to Login.cfm
.