We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36493
    • 64 Posts
    Thanks for looking

    To clear up the confusing statement:

    When I tried adding &loginResourceId to my [[!Login]] the only change in behaviour is: on entering a correct username/password, the page redirects to the id specified.



    example [[!Login? &tplType=`modChunk` &loginTpl=`lgnRALoginTpl` &loginResourceId=`14`]] call. I’ve placed this in my template so it appears in every page.

    yeah It feels like all I have been doing is flushing permissions and clearing caches

    As a side note I updated Login to 1.2.0 rc2 and added &contexts=`web,other,mgr` if I login from the ’web’ context this works for ’web’ and ’mgr’ but not ’other’.
    But if I try from the ’other’ context it wont log me in to anything. Just a silent fail - (I wish I knew how to debug modx code properly)

    I’m assuming sessions do not persist across different domains could this be stuffing up my ’other’ context.?




      |
      • 3749
      • 24,544 Posts
      Quote from: no at Sep 21, 2010, 05:13 AM

      Thanks for looking

      To clear up the confusing statement:

      When I tried adding &loginResourceId to my [[!Login]] the only change in behaviour is: on entering a correct username/password, the page redirects to the id specified.

      Sorry, I’m still confused. This is the normal behavior. If you don’t include that parameter, Login will redirect to itself. If you do, it will redirect to the specified page. What else would you want it to do? If it’s sending you to the other page, you’ve successfully logged in.

      If you’re trying to redirect to a page that’s in a different context than the login page, I’m not sure that’s possible without a custom snippet on a landing page that initializes the new context, then forwards the user. That’s why I suggested having multiple login pages, one in each front-end context.

      example [[!Login? &tplType=`modChunk` &loginTpl=`lgnRALoginTpl` &loginResourceId=`14`]] call. I’ve placed this in my template so it appears in every page.

      yeah It feels like all I have been doing is flushing permissions and clearing caches

      As a side note I updated Login to 1.2.0 rc2 and added &contexts=`web,other,mgr` if I login from the ’web’ context this works for ’web’ and ’mgr’ but not ’other’.
      But if I try from the ’other’ context it wont log me in to anything. Just a silent fail - (I wish I knew how to debug modx code properly)

      I’m assuming sessions do not persist across different domains could this be stuffing up my ’other’ context.?
      Maybe I’m just being dense, but I still don’t know what you mean by "logging in from the ’other’ context." When user’s log in, they log in to a specific context (the one the Login page is in). They’re not logged in to any other contexts AFAIK, though I don’t know what the new "experimental" &contexts parameter does.
        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
        • 36493
        • 64 Posts
        ok tested it out a little.

        I created a new context no permission changed

        just the min context settings to get the gateway plugin to work

        login didn’t work

        then changed this to a context set by a new index.php(config.core.php,.htaccess) in a folder ’other’

        Now login works smiley

        Login persists regardless if i use "domain1.tld/other" or "domain2.tld/other" (of side interest: this doesn’t persist across for the mgr context)

        - so? if I changed my actual context to this method and then created some rewrite rules or something clean up the url?



          |
          • 3749
          • 24,544 Posts
          That sounds like a good plan.

          As for the mgr context, no front-end login will be of any use in the Manager. Access to contexts in the Manager is only affected by Context Access ACL entries with a context of mgr and they will only affect users who log in with yourdomain.com/manager.
            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
            • 36493
            • 64 Posts
            Sorry, I’m still confused. This is the normal behavior. If you don’t include that parameter, Login will redirect to itself. If you do, it will redirect to the specified page. What else would you want it to do? If it’s sending you to the other page, you’ve successfully logged in.
            Ok sorry for the continued confusion. so hopefully to clear this up:

            The behaviour I get when logging in when in the ’other’ context is: the page refreshes but "$modx->user->isAuthenticated($modx->context->get(’key’));" returns false.

            so if I add &loginResourceId=`14` then it redirects to the resource 14 (which is in the same context as the login call) but still "$modx->user->isAuthenticated($modx->context->get(’key’));" returns false.



            I still don’t know what you mean by "logging in from the ’other’ context." When user’s log in, they log in to a specific context (the one the Login page is in). They’re not logged in to any other contexts AFAIK, though I don’t know what the new "experimental" &contexts parameter does.

            sorry, I have three contexts with the keys of "web", "other" and "mgr". so logging in to ’web’ works but If I try to log in to the context called "other" it does not work.

            Most of my testing was without the &contexts parameter but it does appear to successfully log in the user to the contexts specified.( apart from my "other" context when using the gateway plugin)


            Many Many thanks
              |
              • 32525
              • 27 Posts
              Hi there,

              I’m in a similar position. I am using ModX 2.0.2-pl with Login 1.2.0 rc2 and have a site with multiple contexts (web, and then five others each specific to a domain name). I have a plugin that is operating as a context switch based on the domain name.

              When I try to login within a context other than web, the user object is not populated (web context works perfectly). So for instance I have a login page such as: [tt]http://www.mydomain1.com/user-login.html[/tt] which simply calls in the following code:

              [[!Login? &loginResourceId=`82`]]


              The page redirects successfully to resource 82 (which currently has no access restrictions) when logging in with a valid user, but the ModX user object is empty. I have tested with my own snippet, and also simply by placing the following code in a page:

              [[!Profile]]
              <p>[[+username]] is logged in</p>


              If I edit the Profile snippet and add this, I see that the user object is empty:

              /* verify authenticated status if no user specified */
              if (empty($user) return 'User is empty';


              So the problem it seems, is the fact that the session is not being set in the context in which the login process takes place.

              Extra info: Using MAMP Pro 1.8.3, PHP Version 5.2.11, MySQL 5.1.37
                • 3749
                • 24,544 Posts
                Have you tried the newest version of the Login snippet with the &contexts parameter?
                  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
                  • 36493
                  • 64 Posts
                  Login 1.2.0 rc2 is the newest version - and as far as i can tell the &contexts parameter works well but does not affect this issue.


                  I don’t suppose anyone knows how to write rewriteRules to redirect root to a directory depending on the domain (or a differently named index.php file) that will work with revos friendly urls??

                  update!

                  ha who would of thought it(not me)? but this worked, embarrassedKind of - see new update:

                  # Only apply to URLs on this domain
                  RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
                  
                  # Only apply to URLs that aren't already under folder.
                  RewriteCond %{REQUEST_URI} !^/folder/
                  
                  # Don't apply to URLs that go to existing files or folders.
                  RewriteCond %{REQUEST_FILENAME} !-f
                  RewriteCond %{REQUEST_FILENAME} !-d
                  
                  # Rewrite all those to insert /folder.
                  RewriteRule ^(.*)$ /folder/$1
                  
                  # Also redirect the root folder.
                  RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
                  RewriteRule ^(/)?$ folder/index.php [L]
                  


                  Update2!

                  Ok apparently I didn’t check properly before posting embarrassed
                  subpages don’t work - moved my rewrite inquiries to a more appropriate thread see:
                  http://modxcms.com/forums/index.php/topic,54463.msg315377/topicseen.html#msg315377
                    |
                    • 32525
                    • 27 Posts
                    Quote from: BobRay at Sep 21, 2010, 09:33 PM

                    Have you tried the newest version of the Login snippet with the &contexts parameter?

                    Hi there BobRay, yes I am using the latest version of the snippet and I am using the &contexts parameter but still to no avail. Any ideas?

                    I have been ploughing through the build of the rest of the sites today, but I will be addressing the login pages tomorrow so will be able to have a better look at what’s going on!

                    UPDATE 1:

                    I have just tracked where the $contexts variable goes and it seems to start being a problem in the Core Login processor ([tt]core/model/modx/processors/security/login.php[/tt]):

                    $onBeforeLoginParams = array(
                        'username' => $username,
                        'password' => $givenPassword,
                        'attributes' => array(
                            'rememberme' => & $rememberme,
                            'lifetime' => & $lifetime,
                            'loginContext' => & $loginContext
                        )
                    );
                    
                    $rt = false;  /* $rt will be an array if the event fires */
                    if ($loginContext == 'mgr') {
                        $rt = $modx->invokeEvent("OnBeforeManagerLogin", $onBeforeLoginParams);
                    } else {
                        $rt = $modx->invokeEvent("OnBeforeWebLogin", $onBeforeLoginParams);
                    }


                    $rt is empty...

                    UPDATE 2:

                    smiley I think it is working!!! I have added the ’web’ context to the &contexts parameter in my call and now I can log in. So now my snippet grincall looks like:

                    [[!Login? &loginResourceId=`82` &contexts=`web,mycontext1`]]


                    I’m not sure if this is how it should work, as I would assume that you don’t always necessarily want to log a user into both the web context and another context?!
                      • 10378
                      • 375 Posts
                      Quote from: wiseguy at Sep 22, 2010, 06:15 PM

                      UPDATE 2:

                      smiley I think it is working!!! I have added the 'web' context to the &contexts parameter in my call and now I can log in. So now my snippet  grincall looks like:

                      [[!Login? &loginResourceId=`82` &contexts=`web,mycontext1`]]


                      I'm not sure if this is how it should work, as I would assume that you don't always necessarily want to log a user into both the web context and another context?!

                      Sorry to reply to a very old post - but I can confirm this works! Wow!

                      I was looking for a solution to this problem (I have exactly the same setup as you had) for over a week now! And your post was the rescue!

                      Adding the "web" context to the &contexts parameter did immediately fix the problem!

                      I wonder why this hint still isn't in the official documentation? It should definitely be!


                      Thanks again!
                        Freelancer @bitego http://www.bitego.com
                        ---
                        GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
                        More infos here: http://www.bitego.com/extras/goodnews/