我正在尝试使用以下内容为我的网站的管理文件夹启用页面安全性
我的应用程序的结构就像switch case语句
index.cfm
页面的switch.cfm
进一步将代码定义为:
<cfswitch expression="#mode#">
<cfcase value="admin.1"><cfinclude template="1.cfm"></cfcase>
<cfdefaultcase><cfinclude template="login.cfm"></cfcase>
</cfswitch>
现在我的application.cfc
我定义了这样的
<cfif (NOT structKeyExists( session, "isLoggedIn" )) OR (session.isLoggedIn eq false) AND CGI.query_string contains 'admin'>
<cfinclude template="index.cfm"> - why `index`, it will include the `switch.cfm` and `switch.cfm` has the `defaultcase` of `login.cfm`, so apparently it will include `login.cfm` - **This is why i think it should do**.
现在当我将我的页面称为:
http://localhost/?mode=admin.1
- 它进入它,而不是将用户发送到login.cfm
,我错过了什么
答案 0 :(得分:1)
我相信你的逻辑错了......
你在说:
如果未登录,请包含index.cfm
在index.cfm中你要问,
如果mode == admin.1则包含1 否则包括登录
您正在传递正确的模式,因此运行admin.1。
您可能需要以下内容:
<cfif (NOT structKeyExists( session, "isLoggedIn" )) OR (session.isLoggedIn eq false) AND CGI.query_string contains 'admin'>
<cfinclude template="login.cfm">
<cfelse>
<!--- this should mean the user is logged in --->
<cfinclude template="index.cfm">
</cfif>
或类似的......