Skip to main content
Participant
March 4, 2009
Question

Login Error

  • March 4, 2009
  • 1 reply
  • 491 views
Hi,

First time visitor/poster etc.

PLEASE, any help is greatly appreciated. I have attached all relavent code if needed.

Like many I have copied/reused code found; in my case I chose CF 8 Best Practives guide and ALMOST have it working :)

You may visit www.webfuse.net, click on link to login.cfm where you will receive the following error


Element PASSWORD is undefined in LOGINQUERY.


The error occurred in C:\WWW\clients\webfuse\Auth.cfc: line 15

13 : </cfquery>
14 :
15 : <cfif loginQuery.password EQ Hash(password & loginQuery.salt, "SHA-256" )>
16 : <cfset retargs.authenticated = true />
17 : <cfset Session.UserName = uUserName />



My loginQuery is

SELECT client_user_id, hashed_password, salt
FROM t_usernames
WHERE client_username = "ChuckInAtl" (Where "ChuckInAtl" returns correct id, password and salt from my db)



Here is my auth cfc; app.cfc does invoke dblogin.


<cffunction name="dblogin" access="public" output="false" returntype="struct">
<cfargument name="uUserName" required="true" type="string" />
<cfargument name="uPassword" required="true" type="string" />
<cfset var retargs = StructNew()>
<cftry>
<cfif IsValid("regex", uUserName, "[A-Za-z0-9%]*") AND IsValid("regex", uPassword, "[A-Za-z0-9%]*")>
<cfquery name="loginQuery" dataSource="#Request.DSN#" >
SELECT client_user_id, hashed_password, salt
FROM t_usernames
WHERE client_username = <cfqueryparam value="#uUserName#" cfsqltype="CF_SQL_VARCHAR" maxlength="25" />


</cfquery>

<cfif loginQuery.password EQ Hash(password & loginQuery.salt, "SHA-256" )>
<cfset retargs.authenticated = true />
<cfset Session.UserName = uUserName />
<cflog
text="#loginQuery.UserName# has logged in!"
type="Information"
file="access"
application="yes" />
<cfelse>
<cfset retargs.authenticated = false />
</cfif>
<cfelse>
<cfset retargs.authenticated = false />
</cfif>
<cfreturn retargs />
<cfcatch type="database">
<cflog text="Error in dbLogin(). #cfcatch.detail#"
type="Error"
log="Application"
application="yes" />
<cfset retargs.authenticated = false />
<cfreturn retargs />
</cfcatch>
</cftry>
</cffunction>

Thank you,

Chuck
(404) 549-7853
This topic has been closed for replies.

1 reply

Participant
March 5, 2009
Thanks for the help; solved my own problem. Still have to work out roles though.