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!
아니요, 그것은 단순히 사용자 경험의 문제일 것입니다. 저희는 기존 바닐라 포럼을 이전하고 있으며, 기존 사용자들에게 최상의 경험을 제공하려면 "안녕하세요, 포럼에서 새로운 플랫폼으로 이전했습니다. 이 링크를 통해 로그인할 수 있습니다: {link}"라는 이메일을 보내는 것이 가장 좋다고 생각합니다.
안녕하세요, 이 질문을 하는 것이 여전히 적절한 곳인지 모르겠지만, 비밀번호를 잊어버렸을 때 받는 이메일의 유효 기간이 얼마나 되는지 혹시 아시나요? 3일 또는 4일 후 만료된다는 것은 알고 있지만, 옛날 포럼에서 사용자들을 초대해야 해서 이메일이 n일 후 만료될 수 있다는 내용을 알리는 메시지를 보내야 합니다. 따라서 정확한 시간을 알고 싶습니다. 감사합니다.
이 명령어를 사용자별로 실행하거나, 텍스트 파일에 나열된 사용자 목록에 대해서만 실행하는 방법은 무엇인가요? 약 8,000명의 사용자를 이관해야 합니다. API를 통해 사용자를 생성하는 것 자체는 잘 되고 있지만, 하드코딩된 레이트 리미팅 때문에 이메일이 발송되지 않습니다. 또한, 스크리닝된 IP 목록에 제 IP 주소를 ACCEPT로 설정해 두었지만 여전히 작동하지 않습니다. 이 작업은 레일즈 콘솔에서만 수행할 수 있는 것인가요?
그렇게 많은 수의 사용자를 생성하는 것에는 수입 스크립트를 사용하는 것이 더 나은 아이디어일 것 같지만, 이는 주제에서 벗어난 이야기입니다
어쨌든, 스크립트에서 이메일도 함께 보내면 속도 제한(rate limit)에 도달하게 될 것입니다.
이메일 전송 프로세스를 늦추고 싶다면, ruby 루프에 sleep(x) (x는 초 단위)를 추가할 수 있으며, 이는 해당 속도 제한에 맞게 조정되어야 합니다.
스크립트를 장시간 실행할 예정이라면 screen이나 tmux와 같은 세션 관리자를 사용하세요.
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)에서 실행할 수 있습니다.