We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13710
    • 14 Posts
    jazzmatazz2005 Reply #1, 13 years ago
    I have an app that im about to publish soon.
    in my app users create an account (username, password & email).
    Once done a user can login.
    within the app there is an area where users connect to webpages and these webpages are a powered by MODx
    i would like to use the same login information that my app gathers to login into MODx
    is there any way to do this with php


      • 3749
      • 24,544 Posts
      What version of MODX?
        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
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        There are several ways to deal with this. I am working on a similar user validation system, where the actual user registration and user validation is managed by an application external to MODx. I don't really want to duplicate the user data for thousands of users in the application and in MODx, requiring all kinds of back-and-forth activity every time a user's information gets updated.

        The application I'll be accessing has a SOAP service for handling this sort of thing. Since MODx checks the $_SESSION when checking for a valid user, a plugin can be used on page request to make a SOAP request to the application, checking if the user is logged in to the application, fetching appropriate information to populate the $_SESSION array for MODx to access as required. MODx itself doesn't need to permanently store any data about users. This method would mean that your application must have some kind of API for accessing this information. My case will probably be slightly different, as the actual login form is provided by MODx, it just gets POSTed to the application interface instead of a page in MODx.

        Another method would be to duplicate the users in MODx, then pass a token to MODx on page request, using a plugin to trigger a login to MODx as if the user had actually logged in using the MODx system events.
        http://rtfm.modx.com/revolution/2.x/developing-in-modx/other-development-resources/class-reference/modx/modx.invokeevent
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 3749
          • 24,544 Posts
          Probably the simplest thing is to just instantiate MODX in PHP, check to see if the users are already in the MODX DB, add them if not, and then log them in in code using the Login snippet. The exact method will depend on what version of MODX you're using.
            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
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Yes, that would be the simplest. But it doesn't answer the question of how to deal with user data updates in the main application's user management system. Having the same data duplicated like that is always a problem.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 3749
              • 24,544 Posts
              Good point. Discuss maintains a separate user table, which it partially synchronizes with the MODX user table.
                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
                • 13710
                • 14 Posts
                jazzmatazz2005 Reply #7, 13 years ago
                thanks for the replies.
                Im using the latest version of MODx

                I was looking for something that was already built.
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  That's a little difficult, since every application requires different information.

                  There are add-ons for some of the more common authentication systems, such as ActiveDirectory, uLogin to allow using Facebook, Google and other social media and an extension to Login to allow use of Facebook.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org