|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Cfswitch question
Author: Candace Cottrell
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:25165#126585
Gotcha...
Thx
Candace K. Cottrell, Web Developer
The Children's Medical Center
One Children's Plaza
Dayton, OH 45404
937-641-4293
http://www.childrensdayton.org
cottrellc@childrensdayton.org
>>> ian.skinner@bloodsource.org 6/30/2003 11:17:48 AM >>>
Well you could use the pre-cfswitch option...
<cfif IsUserInRole....
<cfelseif IsUserInRole...
<cfelseif IsUserInRole....
<cfelse>
No mathing roles found.
</cfif>
Not quite as clean as a cfswitch...but some of the benifits and should
be a
bit faster then a bunch of complete <cfif></cfif> blocks. This code
block
will stop testing conditions once a match is found. To optimize it,
put
your conditions in order of most likely to least likely.
--------------
Ian Skinner
Web Programmer
BloodSource
Sacramento, CA
Thanks Jim...
Sooo, I guess I have to do this by going through each of my roles and
doing cfifs?
Seems like I am "hardcoding" almost.
Candace K. Cottrell, Web Developer
The Children's Medical Center
One Children's Plaza
Dayton, OH 45404
937-641-4293
http://www.childrensdayton.org
cottrellc@childrensdayton.org
>>> hoflists@depressedpress.com 6/30/2003 11:01:08 AM >>>
It's not illegal, but it won't work.
IsUserInRole() takes a role and returns a Boolean (true/false) - it
really
can't be used in a switch like that. (The "value" attribute looks at
the
RETURN of "expression" - it doesn't act as input to it.)
Jim Davis
----- Excess quoted text cut - see Original Post for more -----
Author: Jim Davis
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:25165#126582
> Thanks Jim...
>
> Sooo, I guess I have to do this by going through each of my roles and
> doing cfifs?
Pretty much.
I've personally never used CFLOGIN, but my own security system is similar.
I create a list of approved roles in each user's session scope and use UDFs
to deal with it. You can do the same thing with "IsUserInRole()"
So instead of really clunky CFIFs you end up with a little more streamlined
CFIFs:
<cfif IsUSerInRole("Admin")>
<h2>Administrator Functions: </h2>
</cfif>
<cfif IsUSerInRole("Facilities")>
<h2>Facilities Functions: </h2>
</cfif>
This is actually a bit more flexible than CFSWITCH in any case as a user can
be in more than one role (I'm not sure if that's possible in your situation,
but using CFIF it's technically simpler - CFSWITCH would stop at the first
match).
Jim Davis
----- Excess quoted text cut - see Original Post for more -----
Author: Ian Skinner
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:25165#126581
Well you could use the pre-cfswitch option...
<cfif IsUserInRole....
<cfelseif IsUserInRole...
<cfelseif IsUserInRole....
<cfelse>
No mathing roles found.
</cfif>
Not quite as clean as a cfswitch...but some of the benifits and should be a
bit faster then a bunch of complete <cfif></cfif> blocks. This code
block
will stop testing conditions once a match is found. To optimize it, put
your conditions in order of most likely to least likely.
--------------
Ian Skinner
Web Programmer
BloodSource
Sacramento, CA
Thanks Jim...
Sooo, I guess I have to do this by going through each of my roles and
doing cfifs?
Seems like I am "hardcoding" almost.
Candace K. Cottrell, Web Developer
The Children's Medical Center
One Children's Plaza
Dayton, OH 45404
937-641-4293
http://www.childrensdayton.org
cottrellc@childrensdayton.org
>>> hoflists@depressedpress.com 6/30/2003 11:01:08 AM >>>
It's not illegal, but it won't work.
IsUserInRole() takes a role and returns a Boolean (true/false) - it
really
can't be used in a switch like that. (The "value" attribute looks at
the
RETURN of "expression" - it doesn't act as input to it.)
Jim Davis
----- Excess quoted text cut - see Original Post for more -----
Author: Candace Cottrell
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:25165#126576
Thanks Jim...
Sooo, I guess I have to do this by going through each of my roles and
doing cfifs?
Seems like I am "hardcoding" almost.
Candace K. Cottrell, Web Developer
The Children's Medical Center
One Children's Plaza
Dayton, OH 45404
937-641-4293
http://www.childrensdayton.org
cottrellc@childrensdayton.org
>>> hoflists@depressedpress.com 6/30/2003 11:01:08 AM >>>
It's not illegal, but it won't work.
IsUserInRole() takes a role and returns a Boolean (true/false) - it
really
can't be used in a switch like that. (The "value" attribute looks at
the
RETURN of "expression" - it doesn't act as input to it.)
Jim Davis
----- Excess quoted text cut - see Original Post for more -----
Author: Jim Davis
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:25165#126571
It's not illegal, but it won't work.
IsUserInRole() takes a role and returns a Boolean (true/false) - it really
can't be used in a switch like that. (The "value" attribute looks at the
RETURN of "expression" - it doesn't act as input to it.)
Jim Davis
----- Excess quoted text cut - see Original Post for more -----
Author: Ian Skinner
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:25165#126567
Don't know, but if so you will need pounds in the expression. I always
forget that.
<cfswithc expression="#IsUserInRole()#>
--------------
Ian Skinner
Web Programmer
BloodSource
Sacramento, CA
Is this illegal?
<Cfswitch expression="IsUserInRole()">
<CfCase value="Admin">
<h2>Administrator Functions: </h2>
</cfcase>
<CfCase value="Facilities">
<h2>Facilities Functions: </h2>
</cfcase>
</Cfswitch>
Candace K. Cottrell, Web Developer
The Children's Medical Center
One Children's Plaza
Dayton, OH 45404
937-641-4293
http://www.childrensdayton.org
cottrellc@childrensdayton.org
Author: Tony Weeg
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:25165#126568
yeah, so that it will actually parse the value of isUserInRole() rather
than validate that the value is actually = "IsUserInRole()" make sense?
tony weeg
uncertified advanced cold fusion developer
tony at navtrak dot net
www.navtrak.net
office 410.548.2337
fax 410.860.2337
I think it should be <Cfswitch expression="#IsUserInRole()#">
<mack />
----- Excess quoted text cut - see Original Post for more -----
Author: Michael Dinowitz
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:25165#126566
IsUserInRole() needs to be in pounds
----- Excess quoted text cut - see Original Post for more -----
Author: Neculai Macarie
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:25165#126564
I think it should be <Cfswitch expression="#IsUserInRole()#">
<mack />
----- Excess quoted text cut - see Original Post for more -----
Author: Candace Cottrell
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:25165#126562
Is this illegal?
<Cfswitch expression="IsUserInRole()">
<CfCase value="Admin">
<h2>Administrator Functions: </h2>
</cfcase>
<CfCase value="Facilities">
<h2>Facilities Functions: </h2>
</cfcase>
</Cfswitch>
Candace K. Cottrell, Web Developer
The Children's Medical Center
One Children's Plaza
Dayton, OH 45404
937-641-4293
http://www.childrensdayton.org
cottrellc@childrensdayton.org
|
May 24, 2012
|
Latest Fusion Authority Articles
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||