Force password change after login

Hello,

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?

Thanks!

Sounds like it would be useful as an option on the discourse-migratepassword plugin. Slightly surprised it isn’t already.

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)

Well, I’m not forcing users to change their password, but we are rendering an alert on every login until they do so.

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)

What do you guys think?

I think it was enabled without an option in the past - if your password was too short, you were required to do a password reset instead.

The policy was flipped because this was locking people out of their accounts (dead email accounts).

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

Привет, нам нужно точно то же самое: мы будем создавать пользователей через API с паролем по умолчанию… После первого входа пользователю следует сменить пароль…

Как вы это реализовали?

Спасибо!

Вместо создания пользователя с паролем по умолчанию следует создать пользователя со случайным паролем и никогда не отправлять его ему. Затем он может использовать ссылку «Забыли пароль» на странице входа, чтобы сначала сбросить пароль, прежде чем войти в систему.

У 99% наших пользователей нет адреса электронной почты ^^, и мы не хотим добавлять так много почтовых ящиков только для «писем о восстановлении пароля». Разве нет другого способа, кроме использования реальных почтовых адресов?

Это станет большой проблемой, так как в Discourse email считается идентификатором…

Если вы хотите иметь полный контроль над процессом входа, чтобы соответствовать вашим стандартам, я рекомендую использовать Официальный единый вход для Discourse (sso).

Discourse теперь поддерживает встроенную возможность истечения срока действия паролей.

Для этого необходимо выполнить:

user = User.find_by_username(username)
UserPasswordExpirer.expire_user_password(user)

Это можно сделать как сотрудникам Discourse для клиентов с хостингом, так и самостоятельно: войдя в контейнер, запустив консоль Rails и выполнив команду для конкретного пользователя.