Link to home
Start Free TrialLog in
Avatar of selms
selmsFlag for United States of America

asked on

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!!!  
Avatar of DanielSKim
DanielSKim

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>
sorry.

<cfif ListFindNoCase(auth.rightsList, i)>

should be:

<cfif ListFindNoCase(SESSION.auth.rightsList, i)>
Avatar of selms

ASKER



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>


Avatar of selms

ASKER



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

I'll try it...
ASKER CERTIFIED SOLUTION
Avatar of DanielSKim
DanielSKim

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of selms

ASKER


IT WORKED!!!   THANKS sooooooo  much for the quick response!!!