Ask a Question related to Macromedia ColdFusion, Design and Development.
-
Mattastic #1
cflogin
Hi, I'm using cflogin to build a simple application. If a user forgets their
password, then they get asked a security question and if they answer it
correctly they get logged in and sent to index.cfm. The problem is when the
user in logged with the questioncheck.cfm, the login promp keeps appearing when
I use cflocation to send them back to the index page. I cant understand this
as the user is logged in, I thought the code between the cflogin tags was
ignored, therefore displaying the index.cfm Here is my code below, hope you
can help
-----------------------application.cfm------------------------------------
<CFSET DataSource = "website">
<cfset application.AdminEmail = "webmaster@halesowen.ac.uk">
<!--- Name our app, and enable Session variables --->
<CFAPPLICATION
NAME="jobportal"
SESSIONMANAGEMENT="Yes">
<cfif IsDefined("URL.Logout")>
<!--- Log out the user or CGI.script_name neq "/portal/registration.cfm"--->
<cflogout>
Thank you for logging out. Please visit again soon
</cfif>
<cflogin>
<cfif CGI.script_name neq "/portal/registration.cfm">
<cfif CGI.script_name neq "/portal/UserLoginForm.cfm" >
<cfif CGI.script_name neq "/portal/questioncheck.cfm" >
<cfif CGI.script_name neq "/portal/question.cfm" >
<cfif not isdefined("email") or not isdefined("password") >
<cfset URL.Message = "Please enter a username and a password">
<CFINCLUDE TEMPLATE="UserLoginForm.cfm">
<CFABORT>
<!--- Otherwise, the user is submitting the login form --->
<!--- This code decides whether the username and password are valid
--->
<cfelse>
query db
<CFQUERY NAME="GetUser" DATASOURCE="#DataSource#">
SELECT FullName, Password FROM jobportal WHERE email =
<cfqueryparam value="#email#" cfsqltype="CF_SQL_VARCHAR"
maxlength="255">
</CFQUERY>
<CFIF GetUser.RecordCount EQ 1 and hash(password) eq
GetUser.password>
user xists
<!--- Tell ColdFusion to consider the user "logged in" --->
<!--- For the NAME attribute, we will provide the user's --->
<!--- ContactID number and first name, separated by commas --->
<!--- Later, we can access the NAME value via GetAuthUser() --->
<CFLOGINUSER
NAME="#GetUser.fullname#"
PASSWORD="#Password#" roles="user">
<!--- Otherwise, re-prompt for a valid username and password --->
<CFELSE>
error
<cfset URL.Message = " Sorry, that username and password are not
recognized.
Please try again.">
<CFINCLUDE TEMPLATE="UserLoginForm.cfm">
<CFABORT>
</CFIF>
</cfif>
</cfif>
</cfif>
</cfif>
</cfif>
</cflogin>
-----------------------questionscheck.cfm------------------------------------
<CFQUERY NAME="GetUser" DATASOURCE="#DataSource#">
SELECT * FROM jobportal WHERE email =
<cfqueryparam value="#email#" cfsqltype="CF_SQL_VARCHAR" maxlength="255">
</CFQUERY>
<CFIF GetUser.answer neq form.Answer>
The answer you have given is not correct. Please try again or regesitor.
<cfelse>ss
<CFLOGINUSER
NAME="#GetUser.fullname#" password="#GetUser.password#"
roles="user">
#getauthuser()#<cflocation url="index.cfm">
</cfif>
Mattastic Guest
-
Using <cflogin>
Is there a way to use CFLOGIN without requiring cookies? If so, how? -
cflogin problem
I am using coldfusion authentication architecture to get the users logged in to my system. Authentication is working ok but it is giving me... -
Doesn't ANYBODY know anything about cflogin???
:Q Do the people on this forum not know anything about cflogin OR is it they do not wish to share??? I posted a ? a week ago and I am still waiting... -
cflogin confusion
Hi I need some help. Ifind lots of tutorials for simple login and for using cflogin in the Application...BUT nothing about using cf_login for single... -
cflogin HELP
Hi I need some help. Ifind lots of tutorials for simple login and for using cflogin in the Application...BUT nothing about using cf_login for single... -
cliffy2009 #2
CFLOGIN
Hey guys,
I have been working on this all weekend and I can get the CFLOGIN to work.
This is my code:
<cfcomponent>
<cffunction name="loginuser" access="remote" returntype="struct">
<cfset var person = StructNew()>
<cfset person.login = "false">
<cfset person.name = "none">
<cfset person.role= "none">
<cflogin idletimeout="0"> <!---user will be logged out automatically after
3 minutes of inactivity--->
<cfif isDefined("cflogin.name") AND isDefined("cflogin.password")>
<cfif cflogin.name EQ "admin" AND cflogin.password EQ "admin">
<cfloginuser name="#cflogin.name#" password="#cflogin.password#"
roles="admin">
<cfset person.login = "true">
<cfset person.role = "admin">
</cfif>
<cfif cflogin.name EQ "user" AND cflogin.password EQ "user">
<cfloginuser name="#cflogin.name#" password="#cflogin.password#"
roles="user">
<cfset person.login = "true">
<cfset person.role = "user">
</cfif>
<cfif person.login EQ "true">
<cfset person.name = getPersonName(cflogin.name, cflogin.password)>
</cfif>
</cfif>
</cflogin>
<cfreturn person>
</cffunction>
<cffunction name="logoutuser" access="public">
<cflogout>
</cffunction>
<cffunction name="getAdminData" access="public" roles="admin"
returntype="string">
<cfreturn "Some Secure Admin Data!">
</cffunction>
<cffunction name="getUserData" access="public" roles="user,admin"
returntype="string">
<cfreturn "Some Secure User Data">
</cffunction>
<cffunction name="getPersonName" access="private" returnType="String">
<cfargument name="loginName" type="string" required="true">
<cfargument name="password" type="string" required="true">
<cfset personName = "none">
<!---hard coded for now, TODO look up in database--->
<CFQUERY NAME="qSecurity" DATASOURCE="Student_IS">
SELECT memID, memFirstName, memLastName, memUserName, memPassword,
RoleName FROM Member
WHERE memUserName = '#cflogin.name#' and memPassword =
'#cflogin.password#'</CFQUERY>
<cfif qSecurity.recordCount EQ 1>
<CFLOGINUSER NAME = "#cflogin.name#"
PASSWORD = "#cflogin.password#"
ROLES = "#trim(qSecurity.RoleName)#">
</cfif>
<!--- <cfif arguments.loginName EQ "admin" AND arguments.password EQ
"admin">
<cfset personName = "Bruce">
<cfelseif arguments.loginName EQ "user" AND arguments.password EQ "user">
<cfset personName = "Mary">
</cfif>--->
<cfreturn QSecurity>
</cffunction>
</cfcomponent>
I don't know why I can't get it to work. Can someone tell me what I am doing
wrong. I am trying to authenticate from a database. Please, Help!!!!
Thank you for your response
If you have a working code, can you email it to me?
cliffy2009 Guest
-
-
mab_bond #4
Re: CFLOGIN
Read this post:
[url]http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=60&catid=585&threadid=1360 931&messageid=4952845[/url]
mab_bond Guest



Reply With Quote

