|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Cfswitch question
Is this illegal?Candace Cottrell 06/30/03 10:57 A I think it should be <Cfswitch expression="#IsUserInRole()#">Neculai Macarie 06/30/03 11:00 A yeah, so that it will actually parse the value of isUserInRole() ratherTony Weeg 06/30/03 11:03 A IsUserInRole() needs to be in poundsMichael Dinowitz 06/30/03 11:01 A It's not illegal, but it won't work.Jim Davis 06/30/03 11:06 A Don't know, but if so you will need pounds in the expression. I alwaysIan Skinner 06/30/03 11:03 A Thanks Jim...Candace Cottrell 06/30/03 11:12 A > Thanks Jim...Jim Davis 06/30/03 11:24 A Well you could use the pre-cfswitch option...Ian Skinner 06/30/03 11:20 A Gotcha...Candace Cottrell 06/30/03 11:27 A 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 I think it should be <Cfswitch expression="#IsUserInRole()#"> <mack /> ----- Excess quoted text cut - see Original Post for more ----- 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 ----- IsUserInRole() needs to be in pounds ----- Excess quoted text cut - see Original Post for more ----- 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 ----- 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 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 ----- > 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 ----- 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 ----- 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 -----
|
September 09, 2010
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||