Importer support for migrated passwords


(Jay Pfaffman) #1

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.


(Jeff Atwood) #2

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


(Régis Hanol) #3

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.


(pmule) #4

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:inblock 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:inassign_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:innew’
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:increate_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:ineach’
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:increate_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:inblock 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:inbatches’
from script/import_scripts/discuz_x.rb:137:in import_users' from script/import_scripts/discuz_x.rb:56:inexecute’
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?


(Jay Pfaffman) #5

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.


(Richard - DiscourseHosting.com) #6

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'],


(Jay Pfaffman) #7

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


(pmule) #8

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?