Solved

Bypass login screen

Posted on 2014-10-13
8
177 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

 

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
 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

724 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