Solved

Bypass login screen

Posted on 2014-10-13
8
160 Views
Last Modified: 2014-10-14
I have an APPLICATION.CFM, EMLLOGIN.CFM, EMLLOGIN1.CFM and EMLLOGOUT.CFM

The EMLLOGOUT.CFM is evoked from any .cfm when the logout button is pressed.

Whenever I click on the logout button, I am presented with the login.cfm screen.

However, when I log in again (the second time),  I get the message "Element USERID is undefined in SESSION."

We are currently on CF9.

Any help would be enormously appreciated.




APPLICATION.CFM
===============
<cfcomponent>
	<cfscript>
		 this.name = "Adminpanel";
		 this.applicationTimeout = createTimeSpan(0,0,10,0);
		 this.clientmanagement= "yes";
		 this.loginstorage = "session";
		 this.sessionmanagement = "yes";
		 this.sessiontimeout = createTimeSpan(0,0,10,0);
		 this.setClientCookies = "yes";
		 this.scriptProtect = "all";

		 this.datasource = "abcdataremote";
	 </cfscript>



	<cffunction  name="onRequestStart">
	  <cfargument name="requestname" required=true/>



		<!--- SESSION LOGOUT --->
		 <cfif isDefined("session.logout")>


				<cfscript>
					StructClear(session);
				</cfscript>

				<cflogout>

		</cfif>

		<cfinclude template="emlLogin1.cfm">

	</cffunction>

</cfcomponent>

Open in new window



EMLLOGIN.CFM
=============
<cfoutput>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- saved from url=(0093)http://www.456bereastreet.com/lab/developing_with_web_standards/csslayout/2-col/finished.html -->
<html lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Contact Info Verification</title>
    <link rel="stylesheet" type="text/css" href="CSSOneColumns.css" media="screen" />
</head>
<body>


    <cfform method="post" action="#cgi.SCRIPT_NAME#" name="adminlogin" id="adminlogin">
		<cfinclude template="emlIncludeHeaderNoNavigation.cfm">
		<p>&nbsp</p>


        <table border="0" cellpadding="0" cellspacing="0" width="100%">
          <tr>
            <td valign="center" align="center"><table class="border" border="0" cellpadding="1" cellspacing="2" width="500">
                <tr>
                  <td><table border="0" cellpadding="0" cellspacing="1" width="100%">
                      <cfif IsDefined('invalid')>
                        <tr>
                          <td align="center" colspan="2"><div class="darkred">#trim(invalid)#</div></td>
                        </tr>
                      </cfif>

                      <tr>
                        <td class="default" align="right" width="160"><strong>Username:&nbsp;</strong></td>
                        <td width="340" align="left"><cfinput type="text" name="j_username" message="Error! Please Provide username" tooltip="Provide Your Username" required="yes" class="inputstyle" id="j_username" tabindex="1" size="25" maxlength="100" value = "D03097"></td>
                      </tr>
                      <tr>
                        <td class="default" align="right" width="160"><strong>Password:&nbsp;</strong></td>
                        <td width="340" align="left"><cfinput type="password" name="j_password" message="Error! Please Provide Password" tooltip="Password Required" required="yes" class="inputstyle" id="j_password" tabindex="2" size="25" maxlength="100" value = "6123324"></td>
                      </tr>
                       <tr>
                        <td align="center">&nbsp;</td>
                        <td align="left"><cfinput type="submit" name="submit" value="Login" class="tinyborder" tabindex="5">
                          </td>
                      </tr>
                  </table></td>
                </tr>
              </table></td>
          </tr>
        </table>
        </cfform>
      </cfoutput>

Open in new window

      
EMLLOGIN1.CFM
=============
<!--- Check for login here --->
<cflogin idletimeout="1800">
<cfif Not IsDefined('cflogin')>
  <cfinclude template="emlLogin.cfm">
  <cfabort>
  <cfelse>
  <cfif cflogin.name IS "" OR cflogin.password IS "">
    <cfset invalid  = "Error! Please Provide Username/Password">
    <cfinclude template="emlLogin.cfm">
    <cfabort>
    <cfelse>
    <cfinvoke component="myComponent" method="getUser" returnvariable="getChkrecords">
		<cfinvokeargument name="inUserId" value="#trim(cflogin.name)#">
		<cfinvokeargument name="inPassword" value="#trim(cflogin.password)#">
    </cfinvoke>
    <cfif getChkrecords.recordCount GT 0>
      <cfloginuser name="#cflogin.name#" Password = "#cflogin.password#" roles="#getChkrecords.lgRole#">
      <cfset session.loggedin = true>
      <cfset session.userid = #trim(cflogin.name)#>
      <cfelse>
      <cfset invalid = "Error! Invalid Username/Password">
      <cfinclude template="emlLogin.cfm">
      <cfabort>
    </cfif>
  </cfif>
</cfif>
</cflogin>	  

Open in new window

EMLLOGOUT.CFM
===========
<cfif StructKeyExists(form,"logout")>
	<cfset session.logout=true>
</cfif>

Open in new window

0
Comment
Question by:Errol Farro
  • 4
  • 4
8 Comments
 
LVL 25

Expert Comment

by:dgrafx
ID: 40380051
The code you posted doesn't even contain "session.userid" except of one occurrence where you are setting it.
Please post code appropriate code.

NOTE: You need to start using Application.cfc instead of Application.cfm. Your onRequestStart is not going to be called automatically when in an Application.cfm like you have coded.
Do some research on how to get started with Application.cfc
0
 

Author Comment

by:Errol Farro
ID: 40380694
I am setting session.userid in emlLogin1.cfm.
If userid and password are valid, then I do <cfset session.userid = #trim(cflogin.name)#>

Btw, I changed the application.cfm to application.cfc and I am  still getting the same result.

Note: I forgot to add a line of code in EMLLOGOUT.CFM. Below please find the complete source for EMLLOGOUT.CFM


<cfif StructKeyExists(form,"logout")>
      <cfset session.logout=true>
</cfif>

cflocation url="emlVerification.cfm">


where emlVerification.cfm is the first screen a user should get after have successfully authenticated himself
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 40380706
i have to ask - did you read (fully and understand) what i said?

look - you said you were getting this error message: "Element USERID is undefined in SESSION."
that means that somewhere in your code you are referring to session.userid

other than where you set the value it does not exist anywhere in the code you posted!

what I actually said was this
>>The code you posted doesn't even contain "session.userid" except of one occurrence where you are setting it.<<
0
 

Author Comment

by:Errol Farro
ID: 40380812
The program that throws the message "Element USERID is undefined in SESSION." is emlVerification.cfm

The logic is as follows
-http://..../emlVerification.cfm
-emlVerification.cfm calls emlConfirmation.cfm
-In emlConfirmation.cfm there is a logout button which calls emlLogout.cfm

Refer to the attached
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:Errol Farro
ID: 40380837
I am trying to attach the files emlVerification.cfm. Can you see it ?
emlVerification.txt
0
 
LVL 25

Accepted Solution

by:
dgrafx earned 500 total points
ID: 40380918
ok so now you include the file where the actual error occurs ...
anyway ...

the cause is because at the point the code (session.userid) is called - the variable no longer exists.
you can't call emlVerification unless you have session.userid set!
where a user logs out you can't then send them to a page that is asking for a session var - in this case session.userid
send them to login when they logout or send them to a home page or something ...
at the very least put this in your onRequestStart function:
<cfif Not StructKeyExists(session, "UserID")>
     <cfset session.UserID=0>
</cfif>
you can add other vars in there as well if needed
also when you go to a page where a user does need to be logged in then send them to login page

good luck
0
 

Author Closing Comment

by:Errol Farro
ID: 40380955
Many many thanks !!!!
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 40381063
glad you got it fixed ...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now