We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36930
    • 22 Posts
    I am having a problem using the Login addon when implemented on a separate context for a subdomian on an existing site.

    The desired functionality is pretty straight forward. When a user goes to the subdomain (intranet.mydomain.com) they should be presented with a login screen. When they login in they are then redirected to a simple page.

    The issue I am currently having is the login compents work fine if I move the login form and the page it redirects to to the 'web' context. But, if they are on the subdomain context, after login, it redirects to the subdomain's error page. So, The login snippets seem to be set up correctly so I am guessing either my permissions are wrong or that the subdomain is not set up properly.

    The site is currently running modx 2.2.7 on our dedicated server. The DNS is being handled at the registrar, and is in control of our client. So, I have pretty free reign to make server adjustments if needed, but DNS changes would be a little more difficult. Currently, the client just set the A record for the domain with the registrar to point it to our server, rather then set the name servers.

    To set up the subdomain locally, I was able to it through cpanel and point them to the same directory as the modx install (I have no clue if this is the right way to do it, but pages on the subdomain context not restricted by the login work as intended)

    Screenshots of permissions, etc that show my current setup below
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      Can you please add your ACL rules for each context (tip: edit the context and use the permissions tab to see), as well as your Login snippet call? Also what is your session_cookie_domain setting set to?

      Do I understand correctly that when users login on the "web" context, they can properly access the subdomain?
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 44234
        • 219 Posts
        Would be best to make sure your subdomain is setup correctly from the start, if only to rule it out. This tutorial worked great for me: http://rtfm.modx.com/display/revolution20/Creating+a+Subdomain+from+a+Folder+using+Virtual+Hosts
          Find me on Twitter, GitHub or Google+
          • 36930
          • 22 Posts
          For the login, I only need it to work on the subdomain. And even then it is only for a simple content page. Basically, the client wants everything on the subdomain behind a login so they can put more sensitive employee info there. Nothing on the 'web' context needs to be behind the login.

          In order to test if the snippet was working correctly, I had moved the login page and the page it redirects to to the 'web' context. When there they work as intended. When I move them back to the subdomain context the login stops working.

          session_cookie_domain is blank

          Attached is what it believe is the ACL rules
            • 3109 ☆ A M B ☆
            • 894 Posts
            Can you post your login snippet code?
              Benjamin Marte
              Interactive Media Developer
              Follow Me on Twitter | Visit my site | Learn MODX
              • 36930
              • 22 Posts
              Oops, here os the login snippet I am using… It is more or less the one provided in the documentation

              [[!Login? &loginTpl=`lgnLoginTpl` &logoutTpl=`lgnLogoutTpl` &errTpl=`lgnErrTpl` &loginResourceId=`62` &logoutResourceId=`61`]]


              I am starting think this may be more tied to how my subdomain is setup. Both contexts are using the same index config and htaccess
                • 3109 ☆ A M B ☆
                • 894 Posts
                Shouldn't be an issue if you're using ContextRouter now if you're doing it manually then yeah there might be something configured incorrectly.

                Which method are you using to host multi-context sites?
                  Benjamin Marte
                  Interactive Media Developer
                  Follow Me on Twitter | Visit my site | Learn MODX
                  • 36930
                  • 22 Posts
                  Well, I have tried two ways now - neither have worked.

                  1. Setup a subdomain via cpanel assigning the public_html directory as the as the document root for both the subdomain as well as the primary domain. I also had contextrouter installed. In this configuration, webpages would display as intended on both the web and subdomain contexts but the login functionality would not work on the subdomain context.

                  2. I followed the example in the virtual hosts link provided by David above. I set the subdomain document root to it's own directory (subdomain-intranet) within the public_html directory. Then copied the index, config, and htaccess files into it, then modified them as directed in the documentation. This seemed to work less. The pages did not load any linked assets (css, js, etc) and the login did not work here either. It would give me a 404 after the login. (I tried this both with contextrouter installed and without)

                  Interestingly though, if I went back to login screen in the second setup, I would have to logout before being able to attempt to log back in. This is not the case in setup one. After logging in and being redirected to the error page, if I return to the login page I don't have to logout before attempting to log in again.

                  Also worth noting, in setup 1, before setting an error page for the context it was going to a somewhat conflicting error page. When no error_page is set, the page that displays says 404 in the page title, but says it's a 503 error in the body of the page.
                    • 3109 ☆ A M B ☆
                    • 894 Posts
                    Yeah this is another big problem when trying to do multi context sites people start doing the manual way when they don't configure ContextRouter properly and it becomes worse.

                    I would suggest you get rid of all the manual stuff you did and just go with ContextRouter the only thing you need to do in cpanel is add the domain the new context is going to use MODX and ContextRouter will take care of the rest no need to edit .htaccess either.

                    Once you get both Contexts working again let's go from there so we can rule out any configuration issues.
                      Benjamin Marte
                      Interactive Media Developer
                      Follow Me on Twitter | Visit my site | Learn MODX
                      • 36930
                      • 22 Posts
                      Both contexts are up and running, sans the login in my subdomain context.

                      The subdomain in question is here:
                      http://intranet.spirehotels.com

                      For example, the testing member page login info is:
                      L: spire
                      P: intraccess

                      All of the initial configuration info from my first couple posts is the same.