Copy link to clipboard
Copied
When I run the code below, I am seeing the 'not defined' message. Why is that?
<cflogin>
<cfloginuser name="x" Password = "y" roles="z">
</cflogin>
<cfif NOT IsDefined("cflogin")>
not defined
</cfif>
Copy link to clipboard
Copied
When I dump the getauthuser() variable, I see "x", which is expected.
Copy link to clipboard
Copied
No, you're not seeing things, @bowshock. I infact noticed something similar with cflogin some days ago. But I put it aside, as I was busy with other matters.
It appears to be a bug. I am curious what the ColdFusion Team makes of it: https://tracker.adobe.com/#/view/CF-4213180
Copy link to clipboard
Copied
I have added a comment to the bug report. It reads:
The following code works. cflogin is dumped as a structure containing the keys "name" and "password".
<cfform>
<cfinput name="j_username" value="me">
<cfinput name="j_password" value="myPW">
<cfinput name="sbmt" value="send" type="submit" >
</cfform>
<cfif isDefined("form.j_username") and isDefined("form.j_password")>
<cflogin>
<cfloginuser name="#form.j_username#" Password = "#form.j_password#" roles="myRole">
<cfdump var="#cflogin#" >
</cflogin>
</cfif>
<!---Cfscript version also works --->
<!---
<cfscript>
if (isDefined("form.j_username") and isDefined("form.j_password")) {
cflogin() {
cfloginuser(name="#form.j_username#", password="#form.j_password#", roles="myRole");
writedump(cflogin);
}
}
</cfscript>
--->
If that is indeed cflogin's intended usage, then the documentation should emphasize:
Copy link to clipboard
Copied
In the above code, you could of course do away with form submission. The code would then simplify to:
<cfset form.j_username="me">
<cfset form.j_password="myPW">
<cflogin>
<cfloginuser name="#form.j_username#" Password = "#form.j_password#" roles="myRole">
<cfdump var="#cflogin#" label="cflogin">
</cflogin>
<!--- alternative --->
<!---
<cfscript>
form.j_username="me";
form.j_password="myPW";
cflogin() {
cfloginuser(name="#form.j_username#", password="#form.j_password#", roles="myRole");
writedump(var=cflogin, label="cflogin");
}
</cfscript>
--->