erikTsomik
asked on
Error message in COLDfusion
Ok here is my task I need to make a warning messaged. Somthing like You can not log in. My log in form working fine I just need to be able to show this message. I tried Javascript but it did not work for me
 <cffunction name="DisplayLoginForm" access="public" returntype="string" output="false">
  Â
      <cfsavecontent variable="txtOutput">
         <cfoutput>
         <div id="test">
            <form  method="post"  name="form">
               <b><i>User Name: </i></b><input type="text" name="txtUserName" size="20"><br />
                <b><i>Password: </i></b><input type="password" name="txtPassword" size="20"><br />
                      Â
                <input type="submit" value="Login >>>" name="Login" >
            </form>
            </div>
                 Â
                 Â
                 Â
         </cfoutput>
      </cfsavecontent>
     Â
      <cfreturn txtOutput />   Â
   </cffunction>
  Â
  Â
   <cffunction name="getFrontEnd" access="public" returntype="struct" hint="Returns front end display." output="true" >
      <cfset var strFrontEnd = StructNew()>
      <cfset strFrontEnd.title = "">
      <cfset strFrontEnd.body = "">
 Â
      <cfquery name="qryOptions" datasource="#this.datasour ce#">
         SELECT    optDefaultPage, txtLoginMessage, txtForgotPass, txtSuccessEmail, txtUnSuccessEmail,    optLoggedOutDefaultPage
         FROM    tblExtranetOptions
         WHERE    intCompanyID = #this.companyId#
      </cfquery>
     Â
     Â
      <cfset strFrontEnd.body = DisplayLoginForm()>
     Â
     Â
      <!---check if the user is authenticated--->
     <cfsetting enablecfoutputonly="yes">
      <cfif isDefined ("form.txtUserName") and isDefined ("form.txtPassword")>
         <cfset admin = createObject('component', 'hb50.ldap').init(this.com panyId)>
            Â
      <cftry>
        <cfset data = admin.login(FORM.txtUserna me, FORM.txtPassword)>
<!--- Â Â Â Â Â Â Â Â <cfset StructAppend(SESSION, data)>--->
             <cfset SESSION.data=data />
            Â
         <cfcatch type="user">
        Â
            <cfset loginError = true>
            <cfset loginErrorText = CFCATCH.message>
            <cfoutput>#loginErrorText# </cfoutput >
         </cfcatch>
      </cftry>
         </cfif>
    Â
              <script language="javascript" type="text/javascript">
                  alert ("you must login before accesing this page");
                  self.location
                 Â
                  </script>   Â
       Â
     Â
         Â
      <cfif isDefined("session.data") and session.data is true>
         <cfset xmlNav = this.navigation.getPublicN avXML()>
            <cfset xmlResult = searchXMLByID(xmlNav, qryOptions.optDefaultPage) >
            <cfif not isSimpleValue(xmlResult)>
               <cfset xmlParent = xmlResult[1]>
               <cfset txtRedirectLink = xmlParent.xmlattributes.ur l>
               <cfif xmlParent.xmlattributes.id NEQ this.webid>                  Â
                  <cflocation url="#txtRedirectLink#" addtoken="no">               Â
               </cfif>
            </cfif>
         <cfelse>
            <cfset xmlNav = this.navigation.getPublicN avXML()>
            <cfset xmlResult = searchXMLByID(xmlNav, qryOptions.optLoggedOutDef aultPage)>
            <cfif not isSimpleValue(xmlResult)>
               <cfset xmlParent = xmlResult[1]>
               <cfset txtRedirectLink = xmlParent.xmlattributes.ur l>
               <cfif xmlParent.xmlattributes.id NEQ this.webid>                  Â
                  <cflocation url="#txtRedirectLink#" addtoken="no">            Â
                 Â
               </cfif>
            </cfif>
        Â
     Â
      </cfif>
        Â
                                                                                                                                                  Â
     Â
      <cfreturn strFrontEnd />
   </cffunction>
   Â
    <cffunction name="logout" access="public" returntype="any">
   </cffunction>
   Â
  Â
</cfcomponent>
 <cffunction name="DisplayLoginForm" access="public" returntype="string" output="false">
  Â
      <cfsavecontent variable="txtOutput">
         <cfoutput>
         <div id="test">
            <form  method="post"  name="form">
               <b><i>User Name: </i></b><input type="text" name="txtUserName" size="20"><br />
                <b><i>Password: </i></b><input type="password" name="txtPassword" size="20"><br />
                      Â
                <input type="submit" value="Login >>>" name="Login" >
            </form>
            </div>
                 Â
                 Â
                 Â
         </cfoutput>
      </cfsavecontent>
     Â
      <cfreturn txtOutput />   Â
   </cffunction>
  Â
  Â
   <cffunction name="getFrontEnd" access="public" returntype="struct" hint="Returns front end display." output="true" >
      <cfset var strFrontEnd = StructNew()>
      <cfset strFrontEnd.title = "">
      <cfset strFrontEnd.body = "">
 Â
      <cfquery name="qryOptions" datasource="#this.datasour
         SELECT    optDefaultPage, txtLoginMessage, txtForgotPass, txtSuccessEmail, txtUnSuccessEmail,    optLoggedOutDefaultPage
         FROM    tblExtranetOptions
         WHERE    intCompanyID = #this.companyId#
      </cfquery>
     Â
     Â
      <cfset strFrontEnd.body = DisplayLoginForm()>
     Â
     Â
      <!---check if the user is authenticated--->
     <cfsetting enablecfoutputonly="yes">
      <cfif isDefined ("form.txtUserName") and isDefined ("form.txtPassword")>
         <cfset admin = createObject('component', 'hb50.ldap').init(this.com
            Â
      <cftry>
        <cfset data = admin.login(FORM.txtUserna
<!--- Â Â Â Â Â Â Â Â <cfset StructAppend(SESSION, data)>--->
             <cfset SESSION.data=data />
            Â
         <cfcatch type="user">
        Â
            <cfset loginError = true>
            <cfset loginErrorText = CFCATCH.message>
            <cfoutput>#loginErrorText#
         </cfcatch>
      </cftry>
         </cfif>
    Â
              <script language="javascript" type="text/javascript">
                  alert ("you must login before accesing this page");
                  self.location
                 Â
                  </script>   Â
       Â
     Â
         Â
      <cfif isDefined("session.data") and session.data is true>
         <cfset xmlNav = this.navigation.getPublicN
            <cfset xmlResult = searchXMLByID(xmlNav, qryOptions.optDefaultPage)
            <cfif not isSimpleValue(xmlResult)>
               <cfset xmlParent = xmlResult[1]>
               <cfset txtRedirectLink = xmlParent.xmlattributes.ur
               <cfif xmlParent.xmlattributes.id
                  <cflocation url="#txtRedirectLink#" addtoken="no">               Â
               </cfif>
            </cfif>
         <cfelse>
            <cfset xmlNav = this.navigation.getPublicN
            <cfset xmlResult = searchXMLByID(xmlNav, qryOptions.optLoggedOutDef
            <cfif not isSimpleValue(xmlResult)>
               <cfset xmlParent = xmlResult[1]>
               <cfset txtRedirectLink = xmlParent.xmlattributes.ur
               <cfif xmlParent.xmlattributes.id
                  <cflocation url="#txtRedirectLink#" addtoken="no">            Â
                 Â
               </cfif>
            </cfif>
        Â
     Â
      </cfif>
        Â
                                                                                                                                                  Â
     Â
      <cfreturn strFrontEnd />
   </cffunction>
   Â
    <cffunction name="logout" access="public" returntype="any">
   </cffunction>
   Â
  Â
</cfcomponent>
ASKER
if the usre is not validated I want them to be redirected to the same page so they can login again
you may have this already throughout your app and I'm not seeing it, but normally I may see it in this order, processing the login before knowing whether or not to display the login form...
 --- is the user attempting to login right now?
<cfif isDefined ("form.txtUserName") and isDefined ("form.txtPassword")>
  check database for user and password
  <cfif login was successfull>
    define session
  </cfif>
</cfif>
<cfif NOT session.user.loggedIn> Â --- is the session in place for the user
  show login page
  stop all other processing
</cfif>
again, you may be all set with this, so if you are, please ignore. Â
Â
ASKER
Well I am providing auathentication against Active directory . But I have the same structure too. I added the arguments but still can not display the form
<cfcomponent displayname="login2" extends="tool">
<cffunction name="init" access="public" returntype="any" output="false">
      <cfargument name="CompanyID" required="true" type="numeric">      Â
      <cfargument name="webid" required="false" default="0">
      <cfargument name="datatype" required="false" default="0">
     Â
      <cfset super.init(CompanyID, arguments.webID, arguments.datatype)>
       <!--- create objects --->
      <cfset this.navigation = createObject("component", "hb50.navigation").init(Co mpanyID)>
      <cfset this.workflow = createObject("component", "hb50.workflow").init(Comp anyID)>
      <cfset this.display = createObject("component", "hb50.display").init(Compa nyID)>
      <cfset this.media = createObject("component", "hb50.media").init(this.Co mpanyID)>
      <cfset this.blnContent = true>
     Â
      <cfscript>
         this.homeData = newFormData();
         this.homeData.tablename = "tblExtranetOptions";
         this.homeData.title = "Extranet Login Options";
         columns = ArrayNew(1);
        Â
         xmlNav = this.navigation.getPublicN avXML();
         x = StructNew();
         x.varname = "optDefaultPage";
         x.title = "Extranet Logged In Default Page";
         x.type = TYPES.SELECT;
         x.xml = xmlNav;
         x.required = true;
         x.multiple = FALSE;
         ArrayAppend(columns, x);
        Â
         x = StructNew();
         x.varname = "optLoggedOutDefaultPage";
         x.title = "Extranet Logged Out Default Page";
         x.type = TYPES.SELECT;
         x.xml = xmlNav;
         x.required = false;
         x.multiple = FALSE;
         ArrayAppend(columns, x);
        Â
         x = StructNew();
         x.varname = "blnLDAP";
         x.title = "Use LDAP for Authentication";
         x.type = TYPES.BOOLEAN;
         x.required = false;
         ArrayAppend(columns, x);
        Â
         x = StructNew();
         x.varname = "txtForgotPass";
         x.title = "Forgot Password";
         x.type = TYPES.HTML;
         x.required = true;
         ArrayAppend(columns, x);
        Â
         x = StructNew();
         x.varname = "txtSuccessEmail";
         x.title = "Password Emailed";
         x.type = TYPES.HTML;
         x.required = true;
         ArrayAppend(columns, x);
        Â
         x = StructNew();
         x.varname = "txtUnSuccessEmail";
         x.title = "Password Not Emailed";
         x.type = TYPES.HTML;
         x.required = true;
         ArrayAppend(columns, x);
         x = StructNew();
         x.varname = "txtLoginMessage";
         x.title = "Login";
         x.type = TYPES.HTML;
         x.required = true;
         ArrayAppend(columns, x);
        Â
         x = StructNew();
         x.varname = "intRoleID";
         x.title = "RoleId";
         x.type = TYPES.NUMBER;
         x.required = false;
         ArrayAppend(columns, x);
        Â
        Â
         this.homeData.columns = columns;
         this.homeData.webid = this.webid;
         this.homeData.blnWorkflow = false;
         this.homeData.blnApproval = false;
         this.homeData.blnLock = false;
         this.homeData.blnVersion = false;
         this.homeData.blnDelete = false;
         this.homeData.blnPreview = false;
         this.homeData.blnCategory = false;         Â
         this.homeData.blnSchedulin g = false;         Â
         this.homeData.blnMeta = true;         Â
         this.homeData.blnResources = false;
         this.homeData.link = this.link;
         this.homeData.varID = "intID";
         return this;
      </cfscript>
   </cffunction>
  Â
   <cffunction name="getTabs" access="public" returntype="any">
      <cfxml variable="xmlNav">
         <cfoutput>
            <item>
               <item caption="Login Options" id="1"/>
            </item>
         </cfoutput>
      </cfxml>
      <cfreturn xmlNav />
   </cffunction>
  Â
   <cffunction name="getBackEnd" access="public" returntype="string" output="true">
      <cfset this.workflow.verifyColumn s(this.hom eData)>
      <!--- process the form in the back end and inserted --->
      <cfset this.display.setActionMsg( this.workf low.proces sForm(this .homeData) )>
      <!--- this actually get the record (only 1) and you continually edit the record after the first time --->
      <cfquery name="qryExtranetOptions" datasource="#this.datasour ce#">
         SELECT *
         FROM tblExtranetOptions
         WHERE intCompanyID = #this.companyID#
      </cfquery>
      <cfif qryExtranetOptions.recordc ount>
         <cfset url.id = qryExtranetOptions.intID>
      </cfif>
      <cfset this.homeData.tabs[1] = StructNew()>
      <cfset this.homeData.tabs[1].capt ion = 'Default Pages'>
      <cfset this.homeData.tabs[1].colu mnlist = 'optDefaultPage,optLoggedO utDefaultP age,blnLDA P'>
      <cfset this.homeData.tabs[2] = StructNew()>
      <cfset this.homeData.tabs[2].capt ion = 'Login'>
      <cfset this.homeData.tabs[2].colu mnlist = 'txtLoginMessage'>
      <cfset this.homeData.tabs[3] = StructNew()>
      <cfset this.homeData.tabs[3].capt ion = 'Emailed'>
      <cfset this.homeData.tabs[3].colu mnlist = 'txtSuccessEmail'>
      <cfset this.homeData.tabs[4] = StructNew()>    `
      <cfset this.homeData.tabs[4].capt ion = 'Not Emailed'>
      <cfset this.homeData.tabs[4].colu mnlist = 'txtUnSuccessEmail'>
      <cfset this.homeData.tabs[5] = StructNew()>
      <cfset this.homeData.tabs[5].capt ion = 'Forgot'>
      <cfset this.homeData.tabs[5].colu mnlist = 'txtForgotPass'>
     Â
      <!--- when user clicks save, update all the blnldap settings for this company --->
      <cfif isDefined("form.button") AND FORM.button eq #translate('Save')#>
         <cfset ldap = 0>
         <cfif isDefined("form.BLNLDAP") AND FORM.BLNLDAP eq 'on'>
            <cfset ldap = 1>
         </cfif>
         <cfquery name="qryUpdateLdap" datasource="#this.datasour ce#">
            UPDATE tblExtranetOptions
            SET blnLDAP = #ldap#         Â
            WHERE intCompanyID = #this.companyID#
         </cfquery>
      </cfif>
      <cfreturn this.display.getAddEdit(th is.homeDat a)>
   </cffunction>
   <cffunction name="DisplayLoginForm" access="public" returntype="string" output="false">
              <cfargument name="txtMessage" type="string" required="yes">
      <cfsavecontent variable="txtOutput">
         <cfoutput>
         <div id="test">
            <form  method="post"  name="form">
               <b><i>User Name: </i></b><input type="text" name="txtUserName" size="20"><br />
                <b><i>Password: </i></b><input type="password" name="txtPassword" size="20"><br />
                                      Â
                <input type="submit" value="Login >>>" name="Login" >
            </form>
            </div>
                 </cfoutput>
           </cfsavecontent>
           <cfreturn txtOutput>
        Â
   </cffunction>
  Â
  Â
   <cffunction name="getFrontEnd" access="public" returntype="struct" hint="Returns front end display." output="true" >
      <cfset var strFrontEnd = StructNew()>
      <cfset strFrontEnd.title = "">
      <cfset strFrontEnd.body = "">
 Â
      <cfquery name="qryOptions" datasource="#this.datasour ce#">
         SELECT    optDefaultPage, txtLoginMessage, txtForgotPass, txtSuccessEmail, txtUnSuccessEmail,    optLoggedOutDefaultPage
         FROM    tblExtranetOptions
         WHERE    intCompanyID = #this.companyId#
      </cfquery>
     Â
      <cfset loginMsg = qryOptions.txtLoginMessage >
      <cfset strFrontEnd.body = DisplayLoginForm(loginMsg) >
     Â
     Â
      <!---check if the user is authenticated--->
     <cfsetting enablecfoutputonly="yes">
      <cfif isDefined ("form.txtUserName") and isDefined ("form.txtPassword")>
         <cfset admin = createObject('component', 'hb50.ldap').init(this.com panyId)>
                      Â
      <cftry>
        <cfset data = admin.login(FORM.txtUserna me, FORM.txtPassword)>
<!--- Â Â Â Â Â Â Â Â <cfset StructAppend(SESSION, data)>--->
                       <cfset SESSION.data=data />
                      Â
         <cfcatch type="user">
        Â
            <cfset loginError = true>
            <cfset loginErrorText = CFCATCH.message>
            <cfoutput>#loginErrorText# </cfoutput >
         </cfcatch>
      </cftry>
         </cfif>
                      Â
            Â
          Â
                Â
           <cfif isDefined("session.data") and session.data is true>
                 <cfset xmlNav = this.navigation.getPublicN avXML()>
                      <cfset xmlResult = searchXMLByID(xmlNav, qryOptions.optDefaultPage) >
                      <cfif not isSimpleValue(xmlResult)>
                            <cfset xmlParent = xmlResult[1]>
                            <cfset txtRedirectLink = xmlParent.xmlattributes.ur l>
                            <cfif xmlParent.xmlattributes.id NEQ this.webid>                                 Â
                                 <cflocation url="#txtRedirectLink#" addtoken="no">                           Â
                            </cfif>
                      </cfif>
                 <cfelse>
                 <cfset
                      <cfset xmlNav = this.navigation.getPublicN avXML()>
                      <cfset xmlResult = searchXMLByID(xmlNav, qryOptions.optLoggedOutDef aultPage)>
                      <cfif not isSimpleValue(xmlResult)>
                            <cfset xmlParent = xmlResult[1]>
                            <cfset txtRedirectLink = xmlParent.xmlattributes.ur l>
                            <cfif xmlParent.xmlattributes.id NEQ this.webid>                                 Â
                                 <cflocation url="#txtRedirectLink#" addtoken="no">                      Â
                                Â
                            </cfif>
                      </cfif>
                Â
          Â
           </cfif>
                Â
                                                                                                                                                                                                                                                                             Â
     Â
      <cfreturn strFrontEnd />
   </cffunction>
      Â
       <cffunction name="logout" access="public" returntype="any">
      </cffunction>
      Â
      Â
     Â
  Â
</cfcomponent>
<cfcomponent displayname="login2" extends="tool">
<cffunction name="init" access="public" returntype="any" output="false">
      <cfargument name="CompanyID" required="true" type="numeric">      Â
      <cfargument name="webid" required="false" default="0">
      <cfargument name="datatype" required="false" default="0">
     Â
      <cfset super.init(CompanyID, arguments.webID, arguments.datatype)>
       <!--- create objects --->
      <cfset this.navigation = createObject("component", "hb50.navigation").init(Co
      <cfset this.workflow = createObject("component", "hb50.workflow").init(Comp
      <cfset this.display = createObject("component", "hb50.display").init(Compa
      <cfset this.media = createObject("component", "hb50.media").init(this.Co
      <cfset this.blnContent = true>
     Â
      <cfscript>
         this.homeData = newFormData();
         this.homeData.tablename = "tblExtranetOptions";
         this.homeData.title = "Extranet Login Options";
         columns = ArrayNew(1);
        Â
         xmlNav = this.navigation.getPublicN
         x = StructNew();
         x.varname = "optDefaultPage";
         x.title = "Extranet Logged In Default Page";
         x.type = TYPES.SELECT;
         x.xml = xmlNav;
         x.required = true;
         x.multiple = FALSE;
         ArrayAppend(columns, x);
        Â
         x = StructNew();
         x.varname = "optLoggedOutDefaultPage";
         x.title = "Extranet Logged Out Default Page";
         x.type = TYPES.SELECT;
         x.xml = xmlNav;
         x.required = false;
         x.multiple = FALSE;
         ArrayAppend(columns, x);
        Â
         x = StructNew();
         x.varname = "blnLDAP";
         x.title = "Use LDAP for Authentication";
         x.type = TYPES.BOOLEAN;
         x.required = false;
         ArrayAppend(columns, x);
        Â
         x = StructNew();
         x.varname = "txtForgotPass";
         x.title = "Forgot Password";
         x.type = TYPES.HTML;
         x.required = true;
         ArrayAppend(columns, x);
        Â
         x = StructNew();
         x.varname = "txtSuccessEmail";
         x.title = "Password Emailed";
         x.type = TYPES.HTML;
         x.required = true;
         ArrayAppend(columns, x);
        Â
         x = StructNew();
         x.varname = "txtUnSuccessEmail";
         x.title = "Password Not Emailed";
         x.type = TYPES.HTML;
         x.required = true;
         ArrayAppend(columns, x);
         x = StructNew();
         x.varname = "txtLoginMessage";
         x.title = "Login";
         x.type = TYPES.HTML;
         x.required = true;
         ArrayAppend(columns, x);
        Â
         x = StructNew();
         x.varname = "intRoleID";
         x.title = "RoleId";
         x.type = TYPES.NUMBER;
         x.required = false;
         ArrayAppend(columns, x);
        Â
        Â
         this.homeData.columns = columns;
         this.homeData.webid = this.webid;
         this.homeData.blnWorkflow = false;
         this.homeData.blnApproval = false;
         this.homeData.blnLock = false;
         this.homeData.blnVersion = false;
         this.homeData.blnDelete = false;
         this.homeData.blnPreview = false;
         this.homeData.blnCategory = false;         Â
         this.homeData.blnSchedulin
         this.homeData.blnMeta = true;         Â
         this.homeData.blnResources
         this.homeData.link = this.link;
         this.homeData.varID = "intID";
         return this;
      </cfscript>
   </cffunction>
  Â
   <cffunction name="getTabs" access="public" returntype="any">
      <cfxml variable="xmlNav">
         <cfoutput>
            <item>
               <item caption="Login Options" id="1"/>
            </item>
         </cfoutput>
      </cfxml>
      <cfreturn xmlNav />
   </cffunction>
  Â
   <cffunction name="getBackEnd" access="public" returntype="string" output="true">
      <cfset this.workflow.verifyColumn
      <!--- process the form in the back end and inserted --->
      <cfset this.display.setActionMsg(
      <!--- this actually get the record (only 1) and you continually edit the record after the first time --->
      <cfquery name="qryExtranetOptions" datasource="#this.datasour
         SELECT *
         FROM tblExtranetOptions
         WHERE intCompanyID = #this.companyID#
      </cfquery>
      <cfif qryExtranetOptions.recordc
         <cfset url.id = qryExtranetOptions.intID>
      </cfif>
      <cfset this.homeData.tabs[1] = StructNew()>
      <cfset this.homeData.tabs[1].capt
      <cfset this.homeData.tabs[1].colu
      <cfset this.homeData.tabs[2] = StructNew()>
      <cfset this.homeData.tabs[2].capt
      <cfset this.homeData.tabs[2].colu
      <cfset this.homeData.tabs[3] = StructNew()>
      <cfset this.homeData.tabs[3].capt
      <cfset this.homeData.tabs[3].colu
      <cfset this.homeData.tabs[4] = StructNew()>    `
      <cfset this.homeData.tabs[4].capt
      <cfset this.homeData.tabs[4].colu
      <cfset this.homeData.tabs[5] = StructNew()>
      <cfset this.homeData.tabs[5].capt
      <cfset this.homeData.tabs[5].colu
     Â
      <!--- when user clicks save, update all the blnldap settings for this company --->
      <cfif isDefined("form.button") AND FORM.button eq #translate('Save')#>
         <cfset ldap = 0>
         <cfif isDefined("form.BLNLDAP") AND FORM.BLNLDAP eq 'on'>
            <cfset ldap = 1>
         </cfif>
         <cfquery name="qryUpdateLdap" datasource="#this.datasour
            UPDATE tblExtranetOptions
            SET blnLDAP = #ldap#         Â
            WHERE intCompanyID = #this.companyID#
         </cfquery>
      </cfif>
      <cfreturn this.display.getAddEdit(th
   </cffunction>
   <cffunction name="DisplayLoginForm" access="public" returntype="string" output="false">
              <cfargument name="txtMessage" type="string" required="yes">
      <cfsavecontent variable="txtOutput">
         <cfoutput>
         <div id="test">
            <form  method="post"  name="form">
               <b><i>User Name: </i></b><input type="text" name="txtUserName" size="20"><br />
                <b><i>Password: </i></b><input type="password" name="txtPassword" size="20"><br />
                                      Â
                <input type="submit" value="Login >>>" name="Login" >
            </form>
            </div>
                 </cfoutput>
           </cfsavecontent>
           <cfreturn txtOutput>
        Â
   </cffunction>
  Â
  Â
   <cffunction name="getFrontEnd" access="public" returntype="struct" hint="Returns front end display." output="true" >
      <cfset var strFrontEnd = StructNew()>
      <cfset strFrontEnd.title = "">
      <cfset strFrontEnd.body = "">
 Â
      <cfquery name="qryOptions" datasource="#this.datasour
         SELECT    optDefaultPage, txtLoginMessage, txtForgotPass, txtSuccessEmail, txtUnSuccessEmail,    optLoggedOutDefaultPage
         FROM    tblExtranetOptions
         WHERE    intCompanyID = #this.companyId#
      </cfquery>
     Â
      <cfset loginMsg = qryOptions.txtLoginMessage
      <cfset strFrontEnd.body = DisplayLoginForm(loginMsg)
     Â
     Â
      <!---check if the user is authenticated--->
     <cfsetting enablecfoutputonly="yes">
      <cfif isDefined ("form.txtUserName") and isDefined ("form.txtPassword")>
         <cfset admin = createObject('component', 'hb50.ldap').init(this.com
                      Â
      <cftry>
        <cfset data = admin.login(FORM.txtUserna
<!--- Â Â Â Â Â Â Â Â <cfset StructAppend(SESSION, data)>--->
                       <cfset SESSION.data=data />
                      Â
         <cfcatch type="user">
        Â
            <cfset loginError = true>
            <cfset loginErrorText = CFCATCH.message>
            <cfoutput>#loginErrorText#
         </cfcatch>
      </cftry>
         </cfif>
                      Â
            Â
          Â
                Â
           <cfif isDefined("session.data") and session.data is true>
                 <cfset xmlNav = this.navigation.getPublicN
                      <cfset xmlResult = searchXMLByID(xmlNav, qryOptions.optDefaultPage)
                      <cfif not isSimpleValue(xmlResult)>
                            <cfset xmlParent = xmlResult[1]>
                            <cfset txtRedirectLink = xmlParent.xmlattributes.ur
                            <cfif xmlParent.xmlattributes.id
                                 <cflocation url="#txtRedirectLink#" addtoken="no">                           Â
                            </cfif>
                      </cfif>
                 <cfelse>
                 <cfset
                      <cfset xmlNav = this.navigation.getPublicN
                      <cfset xmlResult = searchXMLByID(xmlNav, qryOptions.optLoggedOutDef
                      <cfif not isSimpleValue(xmlResult)>
                            <cfset xmlParent = xmlResult[1]>
                            <cfset txtRedirectLink = xmlParent.xmlattributes.ur
                            <cfif xmlParent.xmlattributes.id
                                 <cflocation url="#txtRedirectLink#" addtoken="no">                      Â
                                Â
                            </cfif>
                      </cfif>
                Â
          Â
           </cfif>
                Â
                                                                                                                                                                                                                                                                             Â
     Â
      <cfreturn strFrontEnd />
   </cffunction>
      Â
       <cffunction name="logout" access="public" returntype="any">
      </cffunction>
      Â
      Â
     Â
  Â
</cfcomponent>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Perhaps add an argument to your login method
<cfset err = "invalid username or password">
<cfset strFrontEnd.body = DisplayLoginForm(err)>
Btw, why does this line
 <cfset strFrontEnd.body = DisplayLoginForm()>
Appear before validating login? Â Shouldn't it be after?
You would want to show the login page, if the user is not validated...