How about this, in application.cfm add:

<cflogin idletimeout="3600" applicationtoken="appname"><!--- 1h --->
<cftrace inline="false" text="Need to log on to the secure area">
<cfif isDefined("form.username") and isDefined("form.password")>
  <cfif lcase(form.username) eq "yourname" and lcase(form.password) eq
"blah">
   <cfloginuser name="#form.username#" password="#form.password#"
roles="admin">
   <cftrace inline="false" text="Secure area authentication success">
  <cfelse>
   <cftrace inline="false" text="Secure area authentication failature">
   <cfset authFailed = true>
  </cfif>
</cfif>
<cfif FindNoCase("login.cfm",GetBaseTemplatePath(),1) eq 0>
  <cftrace inline="false" text="Need to log on - sending to login page.">
  <cflocation url="" addtoken="No">
</cfif>
</cflogin>

In login.cfm place

<cfif isDefined("url.logout")>
<cflogout><!--- log user out --->
</cfif>
<cfif len(trim(getAuthUser()))>
<cflocation url="" addtoken="No">
</cfif>

<h2>Secure area login</h2>
<form action="" method="post" name="loginform" id="loginform">
<div style="display: block; position: relative; width: 350px;">
<cfif isDefined("authFailed")>
Login has failed, please try again.<br>
</cfif>
User name: <input type="text" name="username" id="username" size="50"
maxlength="100">
Password: <input type="password" name="password" id="password" size="50"
maxlength="20">
<input type="submit" value="    Login    ">
</div>
</form>

TK
  -----Original Message-----
  From: techmike [mailto:[EMAIL PROTECTED]
  Sent: Thursday, June 17, 2004 10:31 AM
  To: CF-Talk
  Subject: authentication...

  I'm looking for a way to password protect a section of a template.  Very
  minimal security.  (define the password in the template as a varible).

  I'm having issues writing this though, anyone have a snippet that could
  give me some ideas?

  Thanks
  Mike
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to