Chapter 17: Application Security
273
Example: orders.cfm
<!--- This example calls the IsAuthorized function. --->
...
<!--- First, check whether a form button was submitted --->
<CFIF IsDefined("form.btnUpdate")>
<!--- Is user is authorized to update or select
information from the Orders data source? --->
<CFIF ISAUTHORIZED("DataSource", "Orders", "update")>
<CFQUERY NAME="AddItem" DATASOURCE="Orders">
INSERT INTO Orders
(Customer, OrderID)
VALUES
<CFOUTPUT>(#Customer#, #OrderID#)</CFOUTPUT>
</CFQUERY>
<CFOUTPUT QUERY="AddItem">
Authorization Succeeded. Order information added:
#Customer# - #OrderID#<BR>
</CFOUTPUT>
<CFELSE>
<CFABORT SHOWERROR="You are not allowed
to update order information.">
</CFIF>
</CFIF>
<CFIF ISAUTHORIZED("DataSource", "Orders", "select")>
<CFQUERY NAME="GetList" DATASOURCE="Orders">
SELECT * FROM Orders
</CFQUERY>
Authorization Succeeded. Order information follows:
<CFOUTPUT QUERY="GetList">
#Customer# - #BalanceDue#<BR>
</CFOUTPUT>
<CFELSE>
<CFABORT SHOWERROR="You cannot view
order information.">
</CFIF>
Summary of Contents for COLDFUSION 4.5-DEVELOPING WEB
Page 1: ...Allaire Corporation Developing Web Applications with ColdFusion ColdFusion 4 5...
Page 14: ...xiv Developing Web Applications with ColdFusion...
Page 26: ...xxvi Developing Web Applications with ColdFusion...
Page 34: ...8 Developing Web Applications with ColdFusion...
Page 70: ...44 Developing Web Applications with ColdFusion...
Page 84: ...58 Developing Web Applications with ColdFusion...
Page 114: ...88 Developing Web Applications with ColdFusion...
Page 148: ...122 Developing Web Applications with ColdFusion...
Page 174: ...148 Developing Web Applications with ColdFusion...
Page 208: ...182 Developing Web Applications with ColdFusion...
Page 244: ...218 Developing Web Applications with ColdFusion...
Page 274: ...248 Developing Web Applications with ColdFusion...
Page 288: ...262 Developing Web Applications with ColdFusion...
Page 300: ...274 Developing Web Applications with ColdFusion...
Page 350: ...324 Developing Web Applications with ColdFusion...
Page 362: ...336 Developing Web Applications with ColdFusion...