Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Importer Tweak: Allow "reset" password type

edited September 2010 in Vanilla 2.0 - 2.8
Some forums use crazy and/or random password hashing algorithms (I'm looking at you SMF.) Since these hashing methods aren't supported by Vanilla, the only viable password type to use for an import is "reset", but the importer has a small bug that prevents this from working very well. I'm including two small code changes for applications/dashboard/models/class.importmodel.php that fix this issue. Could you include these changes in the next update?

In AuthenticateAdminUser(), replace
            $Result = $PasswordHash->CheckPassword($OverwritePassword, GetValue('Password', $Data), $this->GetPasswordHashMethod());
with
            if ($this->GetPasswordHashMethod() == 'reset')
            {
              $Result = true;
            }
            else
            {
              $Result = $PasswordHash->CheckPassword($OverwritePassword, GetValue('Password', $Data), $this->GetPasswordHashMethod());
            }
In InsertUserTable(), replace
        // Set the admin user flag.
        $AdminEmail = GetValue('OverwriteEmail', $this->Data);
        $this->Query('update :_User set Admin = 1 where Email = :Email', array(':Email' => $AdminEmail));
with
        // If doing a password reset, save out the new admin password:
        if ($this->GetPasswordHashMethod() == 'reset')
    {
          $PasswordHash = new Gdn_PasswordHash();
      $Hash = $PasswordHash->HashPassword(GetValue('OverwritePassword', $this->Data));
      
      // write it out.
      $AdminEmail = GetValue('OverwriteEmail', $this->Data);
      $this->Query('update :_User set Admin = 1, Password = :Hash, HashMethod = "vanilla" where Email = :Email', array(':Hash' => $Hash, ':Email' => $AdminEmail));
    }
    else
    {
      // Set the admin user flag.
      $AdminEmail = GetValue('OverwriteEmail', $this->Data);
      $this->Query('update :_User set Admin = 1 where Email = :Email', array(':Email' => $AdminEmail));
    }
Tagged:

Comments

  • will the import tool work with importing and export of v2?

    and, when will the export tool be included in the admin dashboard?
  • TimTim Operations Vanilla Staff

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • ToddTodd Chief Product Officer Vanilla Staff
    @bugslayer. Awesome, thanks!

    @bobtheman. I want to get this in eventually, but there is a tonne of higher priority stuff right now.
  • shozen1shozen1 New
    edited August 2011
    SMF 2 Final work with this?

    Here is what I have come up with so far.

    Followed all the instructions above but met a problem with the following lines:

    // Set the admin user flag.
    $AdminEmail = GetValue('OverwriteEmail', $this->Data);
    $this->Query('update :_User set Admin = 1 where Email = :Email', array(':Email' => $AdminEmail));

    In Vanilla 2 these lines do not exist together. They have been changed and moved around. Therefore the instructions here need to be updated as they no longer apply to those of us who use Vanilla 2.

    Please update this as I suspect it has caused many people alot of heartache. I will be migrating to my SMF forum to Vanilla the minute I can be sure that there is an effective method to export.

    Looking forward to it.


    There was an error rendering this rich post.

Sign In or Register to comment.