0 Replies Latest reply on Feb 28, 2013 9:32 AM by JennHysuick

    cflogin problem

    JennHysuick Level 1

      I've inherited an applicaiton written a long time, and now it's my job to migrate it to our new CF10 server (so I'm just trying to make it work...)

       

      When I go to the main page, it asks me to log in.  When I log in, it successfully sends me to the welcome page, and it knows who I am using getAuthUser() and IsUserInRole().  Now, when I click on a link from the menue (which is displaying properly based on my role), I get sent BACK to the log in page, and at this point, it no longer knows my getAuthUser value.  Make sense?

       

      I've googled, and tried various changes, adn the best I can get it working is how I described above (some changes wouldn't even get past the log in screen).

       

      In my Application.cfc I have:

      <cffunction name="onRequestStart">

           <cfargument name="request" required="true">

                <cflogin>

                <cfif isDefined("form.logon") and len(trim(form.userid)) and len(trim(form.passwd))>

                <cftry>

                                    <cfinvoke component = "#application.com#.myFunction" method = "authenticateAndGetGroups" returnVariable = "usrobj">

                                       <cfinvokeargument name="userid" value="#form.userID#">

                                          <cfinvokeargument name="passwd" value = "#form.passwd#" >

                                 </cfinvoke>

                      <cfif IsStruct (usrobj)>

                                               <cfloginuser name = "#usrobj.userid#" password = "none" roles = "#usrobj.group#">

                      <cfelse>

                                              <cfset loginerror = true>

                                              <cfinclude template="index.cfm">

                                              <cfabort>

                                    </cfif>

                                    <cfcatch>

                                              <cfset loginerror = true>

                                              <cfinclude template="index.cfm">

                                              <cfabort>

                                    </cfcatch>

                          </cftry>

                <cfelse>

                          <cfinclude template="index.cfm">

                          <cfabort>    

                </cfif>

      </cflogin>

      </cffunction>

       

      the index.cfm is (the jist of it anway - only posting the CF code):

           <cfinclude template="/src/index_left.cfm">

           <cfinclude template="/src/index_right.cfm">

       

      index_left.cfm:

           <cfif #getAuthUser()# eq "">

                <cfinclude template="login.cfm">

           <cfelse>

                <cfif IsUserInRole("admin") >

                     <cfinclude template="index_admin.cfm">

                </cfif>

           </cfif>

       

      After I log in the first time, I do see the index_admin.cfm.  Index admin, contains a list of links (only posting one):

           <a href="?page=user_ctrl">User Roles Management</a>

       

      Clicking this link should then trigger the contents of index right (at this point, I have a getUserAuth value, and my isUserInRole('admin') is YES:

       

      index_right code:

           <cfif #getAuthUser()# eq "">

                <cfinclude template="welcome.cfm">

          <cfelse>

               <cfif IsUserInRole("admin") >

                    <cfif IsDefined("URL.user_ctrl")>

                         <cfinclude template="admin/user_ctrl_ui.cfm">

                     </cfif>

                </cfif>

           </cfif>

       

      But instead of going to the admin/user_ctrl_ui.cfm page, I'm back at the log in page.

       

      Again - I did not write this code, and I'm only to ensure that functionality is 'the same' as it was before... so do I keep trying to get cflogin to work, or do I start changing all the code to do some other sort of log in?

       

      Thanks! 

       

      Jenn