Copy link to clipboard
Copied
I have an external login service that I'm using to authenticate users. After logging in, I get an XML file from which I can pull things like user ID and rights.
The login page redirects to an index page in another folder (which is protected by the authentication service) and on that page, I have a <cfif> statement that looks at rights.
The rights returned are "J" (for judge) and "A" (for admin), which I'm setting as the session variable: session.rights
If I do this:
<cfif session.rights eq "A">
admin section
<cfelseif session.rights eq "J">
judge section
<cfelse>
redirect to the login page
</cfif>
The else is what triggers. If I cfoutput #session.rights# I get J, but for some reason, J does not equal J. I've tried trimming it and everything, to no avail.
Any ideas?
there's your problem. Session.rights does not = "J", it's a block of XML. You'd need to at least say
<cfelseif session.rights.XmlText eq "J">
Copy link to clipboard
Copied
could it be possible that session.rights has some whitespace around it e.g. " J" or "J " ? When you output it you'll only see 'J' but session.rights EQ "J" == false. You may just need to trim it:
<cfelseif trim(session.rights) eq "J">
Copy link to clipboard
Copied
Please do a <CFDUMP VAR="#session#"> and paste the results here. Try an IS as opposed to EQ as well, to see if that helps.
Copy link to clipboard
Copied
Yeah, I've trimmed everything everywhere, to no avail.
Here's the dump result:
struct | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
emailaddr | [empty string] | ||||||||||||||||||
newitem | 1 | ||||||||||||||||||
rights |
| ||||||||||||||||||
sessionid | f0306d37e90bce8a818d7d7843e36516f1e7 | ||||||||||||||||||
tpeauser | <?xml version="1.0" encoding="UTF-8"?> <NAME_FIRST>Dave</NAME_FIRST> <?xml version="1.0" encoding="UTF-8"?> <NAME_LAST>Johnson</NAME_LAST> | ||||||||||||||||||
trackingno | 0 | ||||||||||||||||||
upacsid | [empty string] | ||||||||||||||||||
upacsserver | [empty string] | ||||||||||||||||||
urltoken | CFID=26143&CFTOKEN=6071485a4b7e13-F5282421-A324-841F-59919221D2C51604&jsessionid=f0306d37e90bce8a818d7d7843e36516f1e7 | ||||||||||||||||||
userid |
|
Copy link to clipboard
Copied
there's your problem. Session.rights does not = "J", it's a block of XML. You'd need to at least say
<cfelseif session.rights.XmlText eq "J">
Copy link to clipboard
Copied
Good job I asked for a CFDUMP lol
Copy link to clipboard
Copied
tribule wrote:
Good job I asked for a CFDUMP lol
Yes! That was helpful, but it appears we can no longer mark posts as helpful.
Copy link to clipboard
Copied
Go to "Actions" and select "Mark as Helpful".
BreakawayPaul wrote:
Yes! That was helpful, but it appears we can no longer mark posts as helpful.
Regards,
Anit Kumar
Copy link to clipboard
Copied
Anit Kumar Panda wrote:
Go to "Actions" and select "Mark as Helpful".
My only option there is to "Report Abuse".
Copy link to clipboard
Copied
bingo duncan!
Weird, I was setting that variable like this:
<cfset upacscreds = XMLParse(upacsauth)>
<cfset session.rights = upacscreds.user.row[1].tpea_user_type>
What's the proper way to set it so that I don't have to append .XmlText onto everything?
Copy link to clipboard
Copied
I'd simply do
<cfset session.rights = upacscreds.user.row[1].tpea_user_type.XMLText>
Copy link to clipboard
Copied
duncancumming wrote:
I'd simply do
<cfset session.rights = upacscreds.user.row[1].tpea_user_type.XMLText>
Yep, I had *just* figured that out. It was too obvious, which is why it eluded me.