• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

cflogin question

New Here ,
Apr 13, 2022 Apr 13, 2022

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>

Views

115

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2022 Apr 13, 2022

Copy link to clipboard

Copied

When I dump the getauthuser() variable, I see "x", which is expected.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 13, 2022 Apr 13, 2022

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 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2022 Apr 17, 2022

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:

  1.  the exact conditions in which the cflogin structure will be available;
  2.  the fact that the cflogin structure will then be available only within the cflogin tag or function.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2022 Apr 17, 2022

Copy link to clipboard

Copied

LATEST

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>
--->

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation