I have migrated users from old forum database. Is there any way to send password reset e-mails in bulk? I’ve tried to use API but got You have performed this action too many times, try again later. after requesting to send about 3 reset emails… (other API actions work fine)
I’d be happy to use ruby console or API if you can please advise how to go around that rate limit. It is probably limit per IP address as I’ve investigated.
[updated]
Seems like RateLimiter for ‘forgot_password’ is unfortunately hardcoded so I went ruby script way…
For mass reseting (sending out tokens for password reset to all users) you can do
cd /var/discourse
./launcher enter app
Then create new file mass-password-reset.rb using your favourite editor with following script:
User.all.each do |u|
email_token = u.email_tokens.create(email: u.email)
Jobs.enqueue(:critical_user_email, type: :forgot_password, user_id: u.id, email_token: email_token.token)
sleep(5)
end
And then run it with rails r mass-password-reset.rb
Awesome, thanks! I recently migrated data from my old forum and when tried to manually reset passwords for my users (not too many of them), ran into error message. Discourse logs didn’t show anything, tried to rebuild app and it didn’t help. Then tried your script and now via outsourced email sending service (and Sidekiq) I see that these mails are sending out. So, thanks again!
user = User.find_by(username: 'alehandrof')
if user
email_token = user.email_tokens.create(email: user.email)
Jobs.enqueue(:critical_user_email, type: :forgot_password, user_id: user.id, email_token: email_token.token)
end
没有必要为此创建一个 Ruby 文件;你可以在 Rails 控制台中运行它(./launcher enter app 然后 rails c)。