Skip to main content
December 15, 2008
Question

cflogin and GetAuthUser() - GetUserRoles()

  • December 15, 2008
  • 1 reply
  • 544 views

This is weird... I've gone through the docs and searched this forum but I can't seem to find anyone with the same issue. As a preface, this is my first time working with role based security.

In my auth.cfc I've got a function that does a cflogin with the username/password/role based on what a SQL query comes back with. The cflogin appears to be working with a caveat. When I call a #GetAuthUser()# or a #GetUserRoles()# nothing is returned. Take this sample code for instance:

<cfloginuser name="bob" password="mypassword" roles="test">
<cfoutput>I am: #GetAuthUser()# - #GetUserRoles()#</cfoutput>

When the getauthuser() and getuserroles() gets called, all I see is "I am: ".

Also, I tried to set a test "secure" function:
<cffunction name="testSecure" access="remote" returntype="query" roles="FailThisRole">
<cfoutput>It worked: #variables#</cfoutput>
</cffunction>

When I try to run that function it workes even though that role does not exist nor does it appear that the roles are being assigned to the user.

Any ideas on what is going on here?

TIA!
    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    December 16, 2008
    You must be doing something else besides. When I run your code,

    <cfloginuser name="bob" password="mypassword" roles="test">
    <cfoutput>I am: #GetAuthUser()# - #GetUserRoles()#</cfoutput>


    I get

    I am: bob - test

    Remember that when you run the cfloginuser tag outside the cflogin framework, its effect lasts for just one request.