Skip to main content
Participant
April 13, 2022
Question

cflogin question

  • April 13, 2022
  • 1 reply
  • 265 views

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>

    This topic has been closed for replies.

    1 reply

    bowshockAuthor
    Participant
    April 13, 2022

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

     

    BKBK
    Community Expert
    Community Expert
    April 13, 2022

    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 

    BKBK
    Community Expert
    Community Expert
    April 17, 2022

    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.