Quote from: jrotering at Jun 04, 2010, 01:04 PM
I know there are no dumb questions, but this really feels like one.
It’s not.
Quote from: jrotering at Jun 04, 2010, 01:04 PM
When one is using MODx to build/manage a login-based website, is it generally always recommended to use the user management that is built in? I recently worked on a site with a registration/profile creation component. We built it such that it stored the entire user profile, including login and password, in an external database. It never even occurred to me to tie in to the MODx user account stuff. If that would have been more logical/efficient, could someone explain what the benefits are?
Definitely recommended (and a tutorial is in process); Revolution already loads a session and user object (even if the user is anonymous with id 0), so the major benefit would be utilizing the infrastructure that is there without adding unnecessary bloat or complexity. By extending the modUser object, you can store your data in the external table, define additional related table objects, even authenticate against it with a plugin (and keep the password external only), while also creating a simple modUser object that will make any Extra that already works with the MODx user and security system automatically compatible. Being able to define granular security policies for any core or custom object in the system is a benefit of utilizing the security system, etc. There are probably many more...in short: yes, but you can also do what you want if you’re really stubborn, or really need to bypass it. You can even provide a custom session_handler_class if you need to.
Quote from: jrotering at Jun 04, 2010, 01:04 PM
Second, if I had done it that way, how should I have handled all the fields that aren’t in the standard MODx user table? Is it better to create custom fields and get all the data in the MODx tables, or to just use MODx to handle the basic account info and login fuctionality, and keep the other stuff elsewhere?
Extending the modUser table class allows you to define relationships to external tables if you need to. Just model/reverse-engineer them with xPDO and add an aggregate or composite relationship to it using the
external_key field in modUser or by storing the modUser
id in your external table. The
external_key field and
external_data field in modUser you can now utilize for storing foreign keys to external systems and associated (unlimited) custom data fields. I will also be adding a similar
extended data field to modUserProfile before RC3 that can be used in a similar way on the default user profile object. These data fields are simply JSON objects stored in the database and accessible as a PHP array using the get() and set() methods of modUser/modUserProfile; you can store unlimited custom data in them, they’re reasonably searchable, and they are (or will be soon, in the case of modUserProfile.extended) editable in the manager.
Much more on this soon.