Importer support for migrated passwords

I mostly think that importing passwords from a legacy forum is a Bad Idea. There are almost certainly a bunch of horrible passwords and it seems like making people change their password when they get a shiny new forum is a fine idea, but it seems that people want to do that anyway.

There’s a plugin that offers Migrated password hashes support. I just put that code into the vbulletin importer for some folks. Should I leave it in or take it out before I submit the PR with other useful stuff in it?

Since the passwords are completely ignored unless the plugin is installed, it doesn’t hurt much to just include the passwords, but I’d probably add a switch so that they’d not be included by default.

6 Likes

Maybe include it but default it to off? Explain the downsides in the place where you would enable it?

5 Likes

I think it’s fine to always import previous password hashes & salts. It’s just text, so that won’t take too much space. That way, people who want to allow their users to use their previous password can just add the linked plugin and be done.

3 Likes

Hi all. I am trying to migrate a forum from discuz x to discourse (v2.0.0.beta4), but running the corresponding import script results

creating users
1 / 242 ( 0.4%) /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:48:in _assign_attribute': unknown attribute 'import_pass' for User. (ActiveModel::UnknownAttributeError) from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:40:in block in _assign_attributes’
from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:39:in each' from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:39:in _assign_attributes’
from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activerecord-5.1.4/lib/active_record/attribute_assignment.rb:26:in _assign_attributes' from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:33:in assign_attributes’
from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activerecord-5.1.4/lib/active_record/core.rb:337:in initialize' from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activerecord-5.1.4/lib/active_record/inheritance.rb:66:in new’
from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activerecord-5.1.4/lib/active_record/inheritance.rb:66:in new' from /home/localadmin/git/discourse/script/import_scripts/base.rb:313:in create_user’
from /home/localadmin/git/discourse/script/import_scripts/base.rb:242:in block in create_users' from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/rack-mini-profiler-0.10.7/lib/patches/db/mysql2.rb:6:in each’
from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/rack-mini-profiler-0.10.7/lib/patches/db/mysql2.rb:6:in each' from /home/localadmin/git/discourse/script/import_scripts/base.rb:230:in create_users’
from script/import_scripts/discuz_x.rb:163:in block in import_users' from /home/localadmin/git/discourse/script/import_scripts/base.rb:824:in block in batches’
from /home/localadmin/git/discourse/script/import_scripts/base.rb:823:in loop' from /home/localadmin/git/discourse/script/import_scripts/base.rb:823:in batches’
from script/import_scripts/discuz_x.rb:137:in import_users' from script/import_scripts/discuz_x.rb:56:in execute’
from /home/localadmin/git/discourse/script/import_scripts/base.rb:46:in perform' from script/import_scripts/discuz_x.rb:1064:in

It seems that the custom field “import_pass” are failed to handle somewhere.
Does this happen because some plugins are absent with my environment?

Change it to password instead of import_pass. Or, if you’re not going to use the migrate-passwords plugin, just comment out or delete that line.

Changing it to password will probably not do the trick, because there is a separate salt field a few lines below. It should probably be something like

password: user['password_hash']+':'+user['salt']

and then delete the lines

import_pass: user['password_hash'],

and

salt: user['salt'],

2 Likes

Oops! Thanks, Richard. @pmule, if you want imported passwords to work, you should pay attention to this!

Thanks. Now the import_users passed, but now it failed on import_categories when executing

raw = process_discuzx_post(row['rules'], nil)
          if @bbcode_to_md
            raw = raw.bbcode_to_md(false) rescue raw
          end
          category.topic.posts.first.update_attribute(:raw, raw)

with error

creating categories
       14 / 52 ( 26.9%)  script/import_scripts/discuz_x.rb:288:in `block (2 levels) in import_categories': undefined method `update_attribute' for nil:NilClass (NoMethodError)
	from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/core_ext/object/try.rb:17:in `public_send'
	from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/core_ext/object/try.rb:17:in `try!'
	from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/core_ext/object/try.rb:6:in `try'
	from /home/localadmin/git/discourse/script/import_scripts/base.rb:451:in `create_category'
	from /home/localadmin/git/discourse/script/import_scripts/base.rb:417:in `block in create_categories'
	from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/rack-mini-profiler-0.10.7/lib/patches/db/mysql2.rb:6:in `each'
	from /home/localadmin/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/rack-mini-profiler-0.10.7/lib/patches/db/mysql2.rb:6:in `each'
	from /home/localadmin/git/discourse/script/import_scripts/base.rb:398:in `create_categories'
	from script/import_scripts/discuz_x.rb:263:in `import_categories'
	from script/import_scripts/discuz_x.rb:57:in `execute'
	from /home/localadmin/git/discourse/script/import_scripts/base.rb:46:in `perform'
	from script/import_scripts/discuz_x.rb:1065:in `<main>'

Does the last call legal?