Solved

Bypass login screen

Posted on 2014-10-13
8
163 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Coldfusion CFMESSAGEBOX Passing Variables 6 118
ColdFusion MS SQL CSV Impport 10 66
Query help 4 80
ColdFusion Need assistance updating my legacy zip function 13 40
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 …
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 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