Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forgot Password with application.cfm for admin site

Status
Not open for further replies.

mlm823

Programmer
Oct 29, 2003
39
US
I've created an administrative site for a client which allows them to control their content for a site. It has the standard login/application.cfm structure. They have asked me to add the capability for them to get an email if they forget their password... I put a link on the login screen but everytime I click the link - I get the login screen again... what do I need to do so that I get directed to the emailReminder screen?

Here is the code for application.cfm
<!--- Application.cfm --->

<!--- variables used throughout Admin Site --->

<cfset DSN = &quot;vivian&quot;> <!--- dsn value --->
<cfset encryptKey = &quot;vande&quot;> <!--- encryption key value (used for passwords) --->

<cfset BImagePath = &quot;../images/background/&quot;>
<cfset PImagePath = &quot;../images/photo/&quot;>
<cfset CImagePath = &quot;../images/bookcovers/&quot;>


<!--- Name of application and session management --->
<CFAPPLICATION NAME=&quot;VivianAdmin&quot; SESSIONMANAGEMENT=&quot;Yes&quot;>
<!--- set the messages of no permission or required fields --->
<cfset No_Permission = &quot;You don't have access to this site.&quot;>
<cfset Required_Items = &quot;You need to enter a user id and password.&quot;>
<!--- set the sesssion.loggedOff variable --->
<CFLOCK TIMEOUT=&quot;3&quot; NAME=&quot;#Session.CFID#&quot; TYPE=&quot;EXCLUSIVE&quot;>
<cfparam name=&quot;Session.LoggedOff&quot; default=&quot;Yes&quot;>
</CFLOCK>

<!--- If user is not logged in, force him to login now --->
<CFLOCK TIMEOUT=&quot;3&quot; NAME=&quot;#Session.CFID#&quot; TYPE=&quot;EXCLUSIVE&quot;>
<CFIF Session.LoggedOff EQ &quot;Yes&quot; OR (NOT (ISDEFINED(&quot;Session.User&quot;)))>
<CFIF ISDEFINED(&quot;Form.UserLogin&quot;) and ISDEFINED(&quot;Form.UserPassword&quot;)>
<!--- take the inputed password and encrypt it
<cfset pwd = '#TRIM(Form.UserPassword)#'>
<cfset EncPass = encrypt(pwd,encryptKey)>--->
<!--- perform query to see if they are in the database --->
<CFQUERY NAME=&quot;GetUser&quot; DATASOURCE=&quot;#DSN#&quot;>
select *
from Administrators
where LoginName = '#Trim(FORM.UserLogin)#'
</CFQUERY>
<CFIF GetUser.RECORDCOUNT GT 0>
<!--- take the password and see if same as one logged in with --->
<cfset currentPass = #GetUser.Password#>
<cfset DecPass = decrypt(currentPass,encryptKey)>
<CFIF #DecPass# IS #TRIM(Form.UserPassword)#>
<!--- this is a valid login --->
<CFSET Session.LoggedOff = &quot;No&quot;>
<CFSET Session.User = &quot;#GetUser.LoginName#&quot;>
<CFELSE>
<!--- don't have permission --->
<CFSET MESSAGE = &quot;#Variables.No_Permission#&quot;>
<CFINCLUDE TEMPLATE=&quot;login.cfm&quot;>
<CFABORT>
</CFIF> <!--- password similar to stored value --->
<CFELSE>
<!--- don't have permission --->
<CFSET MESSAGE = &quot;#Variables.No_Permission#&quot;>
<CFINCLUDE TEMPLATE=&quot;login.cfm&quot;>
<CFABORT>
</CFIF> <!--- end query if table has user id--->
<CFELSE>
<!--- <CFSET MESSAGE = &quot;#Variables.Required_Items#&quot;> --->
<CFINCLUDE TEMPLATE=&quot;login.cfm&quot;>
<CFABORT>
</CFIF> <!--- end of form values not defined --->
</CFIF>
</CFLOCK>
 
You could try using cgi.script_name to see what page is being loaded. If it's the emailReminder page, don't display the login page. For everything else, display the login page.

<cfif #cgi.script_name# EQ &quot;emailReminder.cfm&quot;>
code to email password....
<cfelse>
<!--- If user is not logged in, force him to login now --->
<CFLOCK TIMEOUT=&quot;3&quot; NAME=&quot;#Session.CFID#&quot; TYPE=&quot;EXCLUSIVE&quot;>
<CFIF Session.LoggedOff EQ &quot;Yes&quot; OR (NOT (ISDEFINED(&quot;Session.User&quot;)))>
<CFIF ISDEFINED(&quot;Form.UserLogin&quot;) and ISDEFINED(&quot;Form.UserPassword&quot;)>
......etc......
</cfif>

Hope This Helps!

Ecobb
- I hate computers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top