I’m migrating a forum to Discourse. I’m using the same approach as the discourse-migratepassword plugin to allow users to log in with their current password, but these passwords may be insecure.
I want to allow the users to log in but force them to change their password after login if doesn’t comply with Discourse’s password settings.
Is there a way to currently do this? If not, where I should look at to implement this as a plugin?
Yeah, we can use that in the plugin too, happy to contribute that back if I implement it.
I was thinking in adding a custom_field to the user and render an alert until the user changes their password, but forcing them to change it sounds like a better option (not sure where to look to achieve this)
I’m setting a user.custom_fields['migratepassword_policy'] = true if the password doesn’t comply with Discourse settings and using that to conditionally render the modal, and we also send a password reset email once after they log in for the first time (with the insecure password)
Yeah, in this case we allow users to get into the platform with their current password, but we will render that modal until they change it (they can click OK or click outside the modal and it will close)
Maybe adding a “contact support if you don’t have access to your email anymore” message will do in case of dead email accounts
Instead of creating a user with a default password you should create the user with a random password and never send it to them. Then they can use the forgot password link on the login page to reset their password first before logging in.
Discourse now supports the native ability to expire passwords.
To do so you will need to run:
user = User.find_by_username(username)
UserPasswordExpirer.expire_user_password(user)
This can be done either by Discourse staff for hosted customers or by entering your container, running a rails console and executing this on the particular users.