Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override password reset email send when creating user if SMTP not set up #2206

Merged
merged 5 commits into from
Oct 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,20 @@ def create
save_worked = false
end
if save_worked
@user.send_reset_password_instructions
flash[:success] = "Successfully created user."
redirect_to(users_path) && return
begin
@user.send_reset_password_instructions
flash[:success] = "Successfully created user."
rescue Net::SMTPFatalError
flash[:success] = "Successfully created user but reset password instructions were not sent:
Net::SMTPFatalError"
rescue StandardError => e
error_message = e.message
flash[:error] = "Failed to create user: Incorrectly configured SMTP config:
#{error_message}"
@user.destroy
ensure
redirect_to(users_path)
end
else
render action: "new"
end
Expand Down