Skip to main content
Known Participant
May 11, 2008
Question

output from ListRest(GetAuthUser()) function not working as I expected

  • May 11, 2008
  • 2 replies
  • 437 views
I am using the <cflogin> function to log users into the site.
My code reads as follows:
<cflogin
<cfloginuser
name="sNameVariable1, sNameVariable2"
password="sPasswordVariable"
roles="sRolesVariable">
</cflogin>
This works fine. The user can login, and using the ListFirst(GetAuthUser()) and ListRest(GetAuthUser()), I can view and assigning these values to variables, I can view the values using the cfdump function.
Example
<cfset sUserFirstName = ListFirst(GetAuthUser())>
<cfset sUserID = ListRest(GetAuthUser())>
<cfoutput><cfdump var="#sUserID#"></cfoutput>
The value held in the sUserID variable is a value created by the CreateUUID() function in the INSERT statement of my user registration page for creating a user ID.
When I use the sUserID in the WHERE section of a query SELECT statement, however, the recordset returned has no data.
Example
SELECT sUserFirstName, sUserLastName
FROM hsprovider
WHERE providerID = '#sUserID#'

but, when I use the literal string that should be held in sUserID, I get the correct recordset. ie
SELECT sUserFirstName, sUserLastName
FROM hsprovider
WHERE providerID = 'STUEVEEXC-DVXTHYY54-DSFK345-ETC-ETC-ETC'

The output is what I want. I have tried various syntax changes in the where statement, with no positive affect. What am I doing wrong? Thanks so much in advance--daniel
This topic has been closed for replies.

2 replies

Known Participant
May 12, 2008
thanks so much--explanation very precise. dan
Inspiring
May 11, 2008
getauthuser() function returns the NAME of authenticated user,
specifically, the NAME passed to <cfloginuser> tag.

i am thus assuming you are passing the userID as part of NAME attribute
to cfloginuser tag.

now look at what you are passing as NAME to your cfloginuser tag:
name="sNameVariable1, sNameVariable2"

see it? see the SPACE after the comma? all cf list functions, including
listrest() assume a COMMA as default list delimiter. thus
listrest(getauthuser()) will return "[SPACE]userID". that is why it does
not work in your sql WHERE clause

several options you have here to work around it:
1) declare a custom delimiter in your listrest() calls:
listrest(getauthuser(), ", ")

2) use trim(listrest(...)) to trim the whitespace

hth


Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/