Adding multiple access levels via SESSION.auth.rightsList


Have this piece of code,  - which works -

<cfif not listFind(SESSION.auth.rightsList, "SuperUser")>
<cfoutput>
"Sorry, You are not authorized to view this page.</strong>
</cfoutput>


How do I add additional access like this:

<cfif not listFind(SESSION.auth.rightsList, "SuperUser" or "Admin" or "OtherAuthorizedUser")>
<cfoutput>
"Sorry, You are not authorized to view this page.</strong>
</cfoutput>


THANKS IN ADVANCE!!!  
selmsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DanielSKimCommented:
did you want something more succinct that this?

<cfset accessList = "SuperUser,Admin,OtherAuthorizedUser" />

<cfset inAccessList = false />
<cfloop list="#accessList#" index="i">
      <cfif ListFindNoCase(auth.rightsList, i)>
            <cfset inAccessList = true />
            <cfbreak />
      </cfif>
</cfloop>

<cfif not inAccessList>
<cfoutput>
"Sorry, You are not authorized to view this page.</strong>
</cfoutput>
0
DanielSKimCommented:
sorry.

<cfif ListFindNoCase(auth.rightsList, i)>

should be:

<cfif ListFindNoCase(SESSION.auth.rightsList, i)>
0
selmsAuthor Commented:


I'm a beginner CFer...

Any way to modify my code so that If the person is NOT a SuperUser or Admin they will be denied acccess to that page???

<cfif not listFind(SESSION.auth.rightsList, "SuperUser")>
<cfoutput>
"Sorry, You are not authorized to view this page.</strong>
</cfoutput>


0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

selmsAuthor Commented:


Ok,   It makes more sense with the <cfif ListFindNoCase(SESSION.auth.rightsList, i)>  Session part.

I'll try it...
0
DanielSKimCommented:
i am not aware of a native cf function that compares the union (same items) of two lists. the below loops thorugh the accessList, and checks to see if it exists in SESSION.auth.rightsList. if not , inAccessList is false. if so, inAccessList is true.

<!--- define approved roles --->
<cfset accessList = "SuperUser,Admin,OtherAuthorizedUser" />

<cfset inAccessList = false />
<cfloop list="#accessList#" index="i">
     <!--- if the user contains a role in the approved roles list, set inAccessList to true --->
     <cfif ListFindNoCase(SESSION.auth.rightsList, i)>
          <cfset inAccessList = true />
          <cfbreak />
     </cfif>
</cfloop>

<cfif not inAccessList>
<cfoutput>
"Sorry, You are not authorized to view this page.</strong>
</cfoutput>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
selmsAuthor Commented:

IT WORKED!!!   THANKS sooooooo  much for the quick response!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.