We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15136
    • 34 Posts
    Revo 2.0.4
    php 5.2.17

    So i'm trying to use login package and it seems to work fine. However, when the user successfully logs in, I want to redirect to another page. Then if he leaves the site and comes back and goes to that login page, it should automatically redirect him to his profile if his session/cookies haven't expired.

    <modified> What i thought was the problem, wasn't the problem so I removed it from this post...
    Everything works in the back end manager UNTIL i use the login addon and actually log a user in. As soon as the user logs in, the entire back end manager goes blank underneath the header and horizontal menu</modified>

    As far as the front end users are concerned, everything is working great. However, inside the manager, when clicking on a resource the entire page goes blank except for the header and horizontal menu I guess you would call it.

    The console shows the following 3 errors.

    <b>Fatal error</b>: Call to a member function prepare() on a non-object in <b>/home/fight/public_html/core/model/modx/processors/system/config.js.php</b> on line <b>19</b>



    MODx.perm is undefined
    http://www.fighthookup.com/manager/assets/modext/sections/resource/update.js?v=204pl2
    Line 21

    MODx.action is undefined
    http://www.fighthookup.com/manager/assets/modext/sections/resource/update.js?v=204pl2
    Line 21


    I am stuck. I've tried everything I can think of. Basically I just need to be able to ask if the user is logged in and then do something.

    Any ideas? [ed. note: jw175303 last edited this post 14 years, 3 months ago.]
      2.2.4 Revolution
      • 15136
      • 34 Posts
      Oh, PS if I removed that snippet call, and clear the cache everything works fine again.
        2.2.4 Revolution
        • 3749
        • 24,544 Posts
        The global $modx is only necessary if the code is inside a function.

        It looks like I need to update the FAQ. wink

        Try this:

        <?php
        
        if ($modx->user->hasSessionContext($modx->context->get('key'))) {
            $redirectPage = $modx->makeUrl(20, "", "", "full");
            $modx->sendRedirect($redirectPage);
        } else {
            return "You are not authenticated!";
        }


        This should also work:

        if ($modx->user->isAuthenticated()) {


        If you ever really need the User ID, you need this:

        $modx->getLoginUserID('web');


        or

        $modx->getLoginUserID($modx->context->get('key));


        or if you already know the user is logged in:

        $modx->user->get('id');



        BTW, I can't imagine any way that that snippet would affect things in the Manager (unless it's really a plugin or you put it in a Manager template). I suspect that it was clearing the cache that made things work again.

        You might try turning off the compress_js and compress_css System Settings in System -> System Settings (type compress in the search box at the upper right).



        ------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using.
        MODX info for everyone: http://bobsguides.com/modx.html [ed. note: BobRay last edited this post 14 years, 3 months ago.]
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 15136
          • 34 Posts
          For some reason I think it just does not like it when I call $modx


          <b>Fatal error</b>: Call to a member function prepare() on a non-object in <b>/home/fight/public_html/core/model/modx/processors/system/config.js.php</b> on line <b>19</b>


          In my last post I forgot to mention that I already did turn off compress_js and compress_css wink

          I'm stumped. The client side behavior is spot on, but the manager just can't take it.
            2.2.4 Revolution
            • 15136
            • 34 Posts
            Anyone?
              2.2.4 Revolution
              • 15136
              • 34 Posts
              So check this out, if I for instance login with firefox into the manager everything works. If I login on the client side as a user of the site, in a new tab, then SHTF in the manager. However if I login as a user on the front end in FF and as the admin in the manager in Safari, then the manager works perfectly fine.

              It seems to me that when the user logs in on the front end, in the same browser, there are some cookie/sessions that get jacked around and so the manager doesn't show up right. Perhaps a security issue or something.

              However, this doesn't explain why ONLY the resources don't show up since I can still access the settings and anything else in the backend except for resources.

              Possible bug in MODX?
                2.2.4 Revolution
                • 3749
                • 24,544 Posts
                It's starting to sound like a browser add-on causing trouble. Disabling the browser plugins would probably be the next step.

                When the Manager gets funky, does reloading the page help?

                BTW, does the user group of the logged-in user have a *Context* Access ACL entry giving rights to the 'web' context (IOW, with a context of 'web')? That's necessary for them to see web resources in the tree.


                If it's still a problem, you might just have a corrupted file somewhere in your install, especially if you used FTP to transfer all the MODX files.


                ------------------------------------------------------------------------------------------
                PLEASE, PLEASE specify the version of MODX you are using.
                MODX info for everyone: http://bobsguides.com/modx.html
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting