We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36435
    • 40 Posts
    Hi guys. i need some help.
    I've got a Joomla 1.5 site with some 200 members, and I need to migrate them onto a new Modx Revo (2.2.5) site. Is there a way to do this, without forcing the users to re-enter their passwords?

    I would normally have just copied the data through phpMyadmin, but I've seen a couple of posts where they said this was a bad idea, and there was talk of API's but I don't understand what they are or how to use them.

    Can anyone please advise me on how to proceed - or at least point me to where I can learn how to use the tools to get this done?

    Thanks

    joe
      • 4172
      • 5,888 Posts
      may be its possible to create extented modUsers with a custom passwordMatches-function
      As long as they use the old joomla-password this will use the joomla hashing-method.
      As soon as they recreate their password the modx-hashing-method will be used.

      Used lastly code like that for imported users from another system:

      you will need to add joomlas own hashing-method

      <?php
      
      class pmUser extends modUser {
          function __construct(xPDO & $xpdo) {
              parent::__construct($xpdo);
              $this->set('class_key', 'pmUser');
          }
      
          /**
           * Determines if the provided password matches the hashed password stored for the user.
           *
           * @param string $password The password to determine if it matches.
           * @param array $options Optional settings for the hashing process.
           * @return boolean True if the provided password matches the stored password for the user.
           */
          public function passwordMatches($password, array $options = array()) {
              $match = false;
      
              // put here the joomla password-hashing method:
              $hashedPassword = md5(addslashes($password) . "kjöklödkfökeörkj3ö34k23ök");
      
              $_SESSION['hashings']['hashedpw'] = $hashedPassword;
              $_SESSION['hashings']['thispw'] = $this->get('password');
      
              $match = ($this->get('password') === $hashedPassword);
              if (!$match && $this->xpdo->getService('hashing', 'hashing.modHashing')) {
                  $options = array_merge(array('salt' => $this->get('salt')), $options);
                  $hashedPassword = $this->xpdo->hashing->getHash('', $this->get('hash_class'))->hash($password, $options);
                  $match = ($this->get('password') === $hashedPassword);
              }
      
              return $match;
          }
      
      
          /**
           * The modUser password field is hashed automatically, and prevent sudo from being set via mass-assignment
           *
           * {@inheritdoc}
           */
          public function set($k, $v = null, $vType = '', $checkhash = true) {
              if (!$this->getOption(xPDO::OPT_SETUP)) {
                  if ($k == 'sudo')
                      return false;
              }
              if ($checkhash && in_array($k, array('password', 'cachepwd')) && $this->xpdo->getService('hashing', 'hashing.modHashing')) {
                  if (!$this->get('salt')) {
                      $this->set('salt', md5(uniqid(rand(), true)));
                  }
                  $vOptions = array('salt' => $this->get('salt'));
                  $v = $this->xpdo->hashing->getHash('', $this->get('hash_class'))->hash($v, $vOptions);
              }
              return modPrincipal::set($k, $v, $vType);
          }
      
      }
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 36435
        • 40 Posts
        Thanks for the response, Bruno...

        Now... how do I use this?
        Joe