-
Notifications
You must be signed in to change notification settings - Fork 220
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
Conversation
📝 Walkthrough📝 WalkthroughWalkthroughThe changes involve modifications to the user creation process in the Changes
Possibly related PRs
Suggested labels
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Could you change this so that instead of just commenting out the send password reset lines, there is code to catch the exception and flash the error? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Outside diff range and nitpick comments (1)
app/controllers/users_controller.rb (1)
130-132
: Reconsider Destroying User on Email FailureDestroying the user record if sending reset password instructions fails might not be ideal, especially if the user was successfully created. This could lead to inconsistent system states and poor user experience.
Consider keeping the user record and notifying an administrator or allowing the user to reset their password manually later. Here's a suggested change:
rescue => e flash[:error] = "Successfully created user but encountered an error: #{e.message}" - @user.destroy redirect_to(users_path)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
If SMTP is not properly set up, creating a user will not send the typical password reset email. Instead, it will create the user but flash a message to the user.
Motivation and Context
With SMTP Config set up with single-sender, the password reset email does not send successfully when creating a new user. Issue #2204
In the case that SMTP is not set up successfully, a user is still created but a message is flashed that the password reset email was not successfully sent.
How Has This Been Tested?
Before:
Creating new user
After:
Creating a user but SMTP not set up.
If error other than SMTP comes up, flash error message and destroy user (since already created but if unusable, no point in keeping).
Types of changes
Checklist:
overcommit --install && overcommit --sign
to use pre-commit hook for lintingOther issues / help required
If unsure, feel free to submit first and we'll help you along.