ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 20th, 2008, 02:58 PM
codemonger codemonger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 151 codemonger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 30 m 42 sec
Reputation Power: 2
Login error, please help

Hello;
I am creating a new log in for a directory in cf8, I got it locking down the directory, and also allowing you to log in, BUT once your in, and click on a link inside the directory, it kicks you out back to the login form. I know, I read the cfdocs and I haven't found anything about directories accept using the server to lock it down. I don't have server control. So I have to write code to do it for me.

Can someone help me find what has to be changed and what I need to change it 2?

here is my code:

LoginCheck.cfm

<cfparam name="FORM.userLogin" type="string">
<cfparam name="FORM.userPassword" type="string">

<cfquery NAME="getUser" datasource="#APPLICATION.dataSource#">
SELECT user.id, user.Fname, user.Lname
FROM user
WHERE userName =<cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.UserLogin#">
AND password =<cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.UserPassword#">
</cfquery>

<cfif getUser.recordCount eq 1>
<cflock scope="Session" type="EXCLUSIVE" TIMEOUT="20">
<cfset SESSION.auth = structNew()>
<cfset SESSION.auth.isLoggedin = "yes">
<cfset SESSION.auth.id = getUser.id>
<cfset SESSION.auth.Fname = getUser.Fname>
</cflock>
<cfquery name="updateLoginInfo" datasource="#APPLICATION.dataSource#">
UPDATE user SET
lastLogin = #CreateOdbcDateTime(now())#,
hits = hits+1
WHERE ID = #val(getUser.Id)#
</cfquery>
<cflocation url="admin/index.cfm">
<cfelse>
<cflocation url="sitemanager.cfm?login=#form.UserLogin#&getUser=#getUser.recordCount#" addtoken="no">
</cfif>

Application.cfc (Inside the directory)

<cffunction name="OnRequestStart" output="false" returntype="void">
<cfif NOT isDefined("SESSION.auth.isLoggedIn")>
<cflocation url="../sitemanager.cfm" addtoken="no">
<cfabort>
<cfelseif isDefined("FORM.UserLogin")>
<cfinclude template="../LoginCheck.cfm">
<cflocation url="admin/index.cfm">
</cfif>
</cffunction>

It is much easier to write this in cf8 then it was in cf5 I must admit, less code and done slightly differently, but this one bug is driving me crazy. Any ideas on what to fix?

Thank you

Codemonger

Reply With Quote
  #2  
Old May 20th, 2008, 03:51 PM
kiteless kiteless is offline
Moderator
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 4,084 kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 10 h 42 m 46 sec
Reputation Power: 780
Do you have an Application.cfc in the site root? Does it have the same application name as the Application.cfc in the secured folder? It looks like your session isn't being recognized by the secure folder's Application.cfc.

Reply With Quote
  #3  
Old May 20th, 2008, 06:56 PM
codemonger codemonger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 151 codemonger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 30 m 42 sec
Reputation Power: 2
Quote:
Originally Posted by kiteless
Do you have an Application.cfc in the site root? Does it have the same application name as the Application.cfc in the secured folder? It looks like your session isn't being recognized by the secure folder's Application.cfc.


Yes there is an application.cfc in the root of the site, and then an application.cfc in the locked directory with a link to the proxyapplication.cfc

I think it is in the code, if I read what I wrote correctly, it is asking you to log in every time you go to a new page, I don't want that.


<cfelseif isDefined("FORM.UserLogin")>
<cfinclude template="../LoginCheck.cfm">
<cflocation url="admin/index.cfm">

I think that is what this block of code is doing. I tried a number of ways of changing it and that didn't work. Any better ideas on how to make the code open up the whole directory so you don't have to log in every time?

Reply With Quote
  #4  
Old May 21st, 2008, 09:19 AM
kiteless kiteless is offline
Moderator
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 4,084 kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 10 h 42 m 46 sec
Reputation Power: 780
Is "admin/index.cfm" the place you want them to go if they are already logged in? Then just do.

<cfif NOT isDefined("SESSION.auth.isLoggedIn")>
<cflocation url="../sitemanager.cfm" addtoken="no">
<cfabort>
<cfelseif isDefined("FORM.UserLogin")>
<cfinclude template="../LoginCheck.cfm">
<cfelse>
<cflocation url="admin/index.cfm">
</cfif>

Also, assuming this App.cfc is already in the admin folder, you can just leave that out and do:

<cfif NOT isDefined("SESSION.auth.isLoggedIn")>
<cflocation url="../sitemanager.cfm" addtoken="no">
<cfabort>
<cfelseif isDefined("FORM.UserLogin")>
<cfinclude template="../LoginCheck.cfm">
</cfif>

And it will just let them get to whatever admin page they were going to as long as they are logged in and as long as form.userLogin is not defined.

Reply With Quote
  #5  
Old May 21st, 2008, 10:09 AM
codemonger codemonger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 151 codemonger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 30 m 42 sec
Reputation Power: 2
Quote:
Originally Posted by kiteless
Is "admin/index.cfm" the place you want them to go if they are already logged in? Then just do.

<cfif NOT isDefined("SESSION.auth.isLoggedIn")>
<cflocation url="../sitemanager.cfm" addtoken="no">
<cfabort>
<cfelseif isDefined("FORM.UserLogin")>
<cfinclude template="../LoginCheck.cfm">
<cfelse>
<cflocation url="admin/index.cfm">
</cfif>

Also, assuming this App.cfc is already in the admin folder, you can just leave that out and do:

<cfif NOT isDefined("SESSION.auth.isLoggedIn")>
<cflocation url="../sitemanager.cfm" addtoken="no">
<cfabort>
<cfelseif isDefined("FORM.UserLogin")>
<cfinclude template="../LoginCheck.cfm">
</cfif>

And it will just let them get to whatever admin page they were going to as long as they are logged in and as long as form.userLogin is not defined.


Ok, I used this code:
<cfif NOT isDefined("SESSION.auth.isLoggedIn")>
<cflocation url="../sitemanager.cfm" addtoken="no">
<cfabort>
<cfelseif isDefined("FORM.UserLogin")>
<cfinclude template="../LoginCheck.cfm">
<cfelse>
<cflocation url="admin/index.cfm">
</cfif>

I get this error:
File not found: /admin/admin/index.cfm

It is adding on an extra admin/ instead of being
admin/index.cfm

Yes there is an application.cfc file in the locked out directory, I also have an application.cfc in root, and it is extended with proxyapplication.cfc for teh locked out directory> (I had to do that, I don't have control of the server)

Now the other code you placed:

<cfif NOT isDefined("SESSION.auth.isLoggedIn")>
<cflocation url="../sitemanager.cfm" addtoken="no">
<cfabort>
<cfelseif isDefined("FORM.UserLogin")>
<cfinclude template="../LoginCheck.cfm">
</cfif>

This allows me to log in, BUT when I click on a link, it kicks me back to sitemanager.cfm.

I was looking into the cflogin tags, not sure if those will give me what I need though. Is it possible to get this code to work?

Reply With Quote
  #6  
Old May 21st, 2008, 10:22 AM
kiteless kiteless is offline
Moderator
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 4,084 kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 10 h 42 m 46 sec
Reputation Power: 780
You probably want to specify an absolute path from the web root, something like

<cflocation url="/admin/index.cfm">

assuming admin is off of your site root.

Reply With Quote
  #7  
Old May 21st, 2008, 10:35 AM
codemonger codemonger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 151 codemonger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 30 m 42 sec
Reputation Power: 2
Quote:
Originally Posted by kiteless
You probably want to specify an absolute path from the web root, something like

<cflocation url="/admin/index.cfm">

assuming admin is off of your site root.


I tried that, it times out.
Admin folder is a folder in the site root.
http://www.mysite.com/admin/index.cfm

Reply With Quote
  #8  
Old May 21st, 2008, 10:39 AM
kiteless kiteless is offline
Moderator
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 4,084 kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 10 h 42 m 46 sec
Reputation Power: 780
Is this login form in the admin folder? Are you going into an infinite cflocation loop trying to redirect them to the same folder that they're already in? If so you don't need the cflocation at all.

Reply With Quote
  #9  
Old May 21st, 2008, 11:35 AM
codemonger codemonger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 151 codemonger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 30 m 42 sec
Reputation Power: 2
Quote:
Originally Posted by kiteless
Is this login form in the admin folder? Are you going into an infinite cflocation loop trying to redirect them to the same folder that they're already in? If so you don't need the cflocation at all.


Ok, if I use the code without the location tag, it lets me log in, BUT if I click on a link it tries to kick me out to the sitemanager.cfm log in. So something on the chcklogin.cfm has to change to stop me from having to log in everytime I want to navigate in the admin folder. So if we look at that code, and make it simple, I added extra, this is the code that actually runs the log in:

<cfparam name="FORM.userLogin" type="string">
<cfparam name="FORM.userPassword" type="string">

<cfquery NAME="getUser" datasource="#APPLICATION.dataSource#">
SELECT user.id, user.Fname, user.Lname
FROM user
WHERE userName =<cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.UserLogin#">
AND password =<cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.UserPassword#">
</cfquery>

<cfif getUser.recordCount eq 1>
<cflock scope="Session" type="EXCLUSIVE" TIMEOUT="20">
<cfset SESSION.auth = structNew()>
<cfset SESSION.auth.isLoggedin = "yes">
<cfset SESSION.auth.id = getUser.id>
<cfset SESSION.auth.Fname = getUser.Fname>
</cflock>
<cflocation url="admin/index.cfm">
<cfelse>
<cflocation url="sitemanager.cfm?login=#form.UserLogin#&getUser=#getUser.recordCount#" addtoken="no">
</cfif>

Now the cfelse, this triggers text on the sitemanager.cfm and gives you texts stating your login was wrong, that's why you get this: sitemanager.cfm?login=#form.UserLogin#&getUser=#getUser.recordCount#

What is wrong on this page since it is an include that is making me have to log on everytime I click a link?

is my timeout too short?

Reply With Quote
  #10  
Old May 21st, 2008, 11:43 AM
kiteless kiteless is offline
Moderator
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 4,084 kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 10 h 42 m 46 sec
Reputation Power: 780
I'm really not sure at this point. What is your session timeout set to? You're sure the two Application.cfc's are using the same application name? You have setClientCookies enabled?

You may want to step back and do a Google search for "coldfusion login example" to go straight to the documentation to try out their example.

Reply With Quote
  #11  
Old June 3rd, 2008, 12:56 PM
codemonger codemonger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 151 codemonger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 30 m 42 sec
Reputation Power: 2
Quote:
Originally Posted by kiteless
I'm really not sure at this point. What is your session timeout set to? You're sure the two Application.cfc's are using the same application name? You have setClientCookies enabled?

You may want to step back and do a Google search for "coldfusion login example" to go straight to the documentation to try out their example.


Just to let you know, once I let the web site go live, the log in worked fine. Must not have liked being on an ip address for some reason.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Login error, please help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT