Solved

Bypass login screen

Posted on 2014-10-13
8
158 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
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 …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

12 Experts available now in Live!

Get 1:1 Help Now