# Cannot login to dev instance with imported user

**URL:** https://meta.discourse.org/t/cannot-login-to-dev-instance-with-imported-user/79544
**Category:** Development
**Created:** [February 1, 2018, 1:49pm UTC](https://meta.discourse.org/t/cannot-login-to-dev-instance-with-imported-user/79544 "2018-02-01T13:49:26Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![fhe](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fhe/32/113345_2.png) [@fhe](https://meta.discourse.org/u/fhe)
#### Post date: [February 1, 2018, 1:49pm UTC](https://meta.discourse.org/t/cannot-login-to-dev-instance-with-imported-user/79544/1 "2018-02-01T13:49:26Z")

</div>

I’ve just imported my first user from IPB to my local Discourse 2.0.0.beta2 and also went on to import the previous passwords using @michaeld’s [discourse-migratepassword](https://github.com/communiteq/discourse-migratepassword).

Everything seems to be working fine, the user is in the database and I’ve verified, that the password check in `discourse-migratepassword` succeeds.

What’s not working is saving the user after setting the raw password. [User.save](https://github.com/communiteq/discourse-migratepassword/blob/5bd28045ca7a0ed22233d453c9524e7cb196b72e/plugin.rb#L103) returns `false`, makes `confirm_password?` to fail and produces this output on the log.

```
I, [2018-02-01T14:31:42.198999 #58525] INFO -- : Started POST "/session" for ::1 at 2018-02-01 14:31:42 +0100
I, [2018-02-01T14:31:42.303772 #58525] INFO -- : Processing by SessionController#create as */*
I, [2018-02-01T14:31:42.305979 #58525] INFO -- : Parameters: {"login"=>"Florian", "password"=>"[FILTERED]"}
D, [2018-02-01T14:31:42.314922 #58525] DEBUG -- : User Load (2.3ms) SELECT "users".* FROM "users" WHERE "users"."username_lower" = 'florian' LIMIT 1
D, [2018-02-01T14:31:42.379916 #58525] DEBUG -- : (1.0ms) SELECT "user_custom_fields"."name", "user_custom_fields"."value" FROM "user_custom_fields" WHERE "user_custom_fields"."user_id" = 1 ORDER BY id asc
D, [2018-02-01T14:31:42.383404 #58525] DEBUG -- : (0.6ms) BEGIN
D, [2018-02-01T14:31:42.400523 #58525] DEBUG -- : UserEmail Load (2.0ms) SELECT "user_emails".* FROM "user_emails" WHERE "user_emails"."user_id" = 1 AND "user_emails"."primary" = 't' LIMIT 1
D, [2018-02-01T14:31:42.427949 #58525] DEBUG -- : UserEmail Exists (2.8ms) SELECT 1 AS one FROM "user_emails" WHERE "user_emails"."email" = 'address@domain.invalid' AND ("user_emails"."id" != 1) LIMIT 1
D, [2018-02-01T14:31:42.433311 #58525] DEBUG -- : UserEmail Exists (1.5ms) SELECT 1 AS one FROM "user_emails" WHERE "user_emails"."primary" = 't' AND ("user_emails"."id" != 1) AND "user_emails"."user_id" = 1 LIMIT 1
D, [2018-02-01T14:31:42.437460 #58525] DEBUG -- : (1.1ms) ROLLBACK
I, [2018-02-01T14:31:42.442319 #58525] INFO -- : Completed 200 OK in 134ms (Views: 0.2ms | ActiveRecord: 25.3ms)

```

It’s my first encounter with Ruby and Rails/ActiveRecord. It would be great if someone could make sense out of my description 🙂

Thanks!  
—Florian

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [February 1, 2018, 2:10pm UTC](https://meta.discourse.org/t/cannot-login-to-dev-instance-with-imported-user/79544/2 "2018-02-01T14:10:20Z")

</div>

The plugin works great, so the number one reason for login issues is usually password related:

> [@Migrate a phpBB3 forum to Discourse](https://meta.discourse.org/t/migrate-a-phpbb3-forum-to-discourse/30810/1):
>
> users won’t be able to login with their old password if it’s considered insecure. By default Discourse requires a minimum password length of 10 chars (for admins it’s 15) and the password must not be on the [list of common passwords][common\_passwords]. But users can always reset their password by clicking the “I forgot my password” link on the login dialog or directly by visiting `https://discourse.example.com/password-reset`

---

<div class="post-metadata">

### Author: ![fhe](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fhe/32/113345_2.png) [@fhe](https://meta.discourse.org/u/fhe)
#### Post date: [February 1, 2018, 3:11pm UTC](https://meta.discourse.org/t/cannot-login-to-dev-instance-with-imported-user/79544/3 "2018-02-01T15:11:03Z")

</div>

Thanks a lot — exactly the reason why it wasn’t working!

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [February 6, 2018, 9:18am UTC](https://meta.discourse.org/t/cannot-login-to-dev-instance-with-imported-user/79544/4 "2018-02-06T09:18:58Z")

</div>

The plugin now features the setting `migratepassword_allow_insecure_passwords` which enables you to work around this issue.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [February 6, 2018, 10:24am UTC](https://meta.discourse.org/t/cannot-login-to-dev-instance-with-imported-user/79544/5 "2018-02-06T10:24:22Z")

</div>

Thanks for adding that setting.

Ideally the plugin would prompt the user to change the password when an insecure password is detected.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [February 7, 2018, 7:54pm UTC](https://meta.discourse.org/t/cannot-login-to-dev-instance-with-imported-user/79544/6 "2018-02-07T19:54:47Z")

</div>

Yeah, allowing the login but setting the login redirect to `/my/preferences/account?needs_password_reset` would probably solve the problem.
