Copy link to clipboard
Copied
I've looked through the code provided on these forums and even copied examples over but my cflogin tag still returns the user back to the login page. When I test cflogin not in the application.cfc file (with the cflogin on a page by itself) it seems to work fine. Can someone provide a second pair of eyes to see where I'm missing something. In the URL it is getting the CFID and CFTOKEN -here's the returned URL after logging in "
mywebsite/home.cfm?CFID=717&CFTOKEN=93369078
This is the application.cfc file:
<cfcomponent>
<cfset This.name = "myapp">
<cfset This.Sessionmanagement="true">
<cfset This.Sessiontimeout="#createtimespan(0,0,30,0)#">
<cfset This.applicationtimeout="#createtimespan(1,0,0,0)#">
<cffunction name="onRequestStart">
<cfargument name = "request" required="true"/>
<cfif IsDefined("Form.logout")>
<cflogout>
</cfif>
<cflogin>
<cfif NOT IsDefined("cflogin")>
<cfinclude template="login.cfm">
it's here
<cfabort>
<cfelse>
<cfquery name="loginQuery" dataSource="#mysource#">
select id,passwd, manager_level from personal
where emplid = '#cflogin.name#'
AND passwd = '#cflogin.password#'
and manager_level <> '8'
</cfquery>
<cfif loginQuery.manager_level NEQ "">
<cfloginuser name="#cflogin.name#" Password = "#cflogin.password#"
roles="#loginQuery.manager_level#">
<cflocation url="home.cfm">
<cfelse>
<cfoutput>
<H2>Your login information is not valid.<br>
Please Try again</H2>
</cfoutput>
<cfinclude template="login.cfm">
<cfabort>
</cfif>
</cfif>
</cflogin>
</cffunction>
</cfcomponent>
And my login form =
<form method="post" action="home.cfm">
ID: <input type="text" name="j_username" size="3" max="11">
password: <input type="text" name="j_password" size="8" max="11">
<input type="submit" name="action" value="Proceed">
Copy link to clipboard
Copied
I've semi fixed the problem. It now lets the user get to the home page but it doesn't appear to be setting the <cfloginuser> variables such as name, password and rolls.
Under the <cflogin> tag I changed the <cfif Not IsDefined("cflogin")> to <cfif NOT IsDefined("form.j_username")>
The example in the documents use the <cfif Not IsDefined("cflogin")> approach but it didn't work for me.
How do you get the variables from cfloginuser or make sure they are set? When using #GetAuthUser()# I do get the j_username but #cflogin.name# or #GetUserRoles()# gives me an error - Variable GetUserRolls is undefined.
Thanks for the help