noggin
noggin copied to clipboard
Handle SMTP exceptions better during password reset
We should handle this better than by giving out a 500 error:
[2021-11-23 11:58:21,836] ERROR in app: Exception on /forgot-password/ask [POST]
Traceback (most recent call last):
File "/opt/app-root/lib/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/opt/app-root/lib/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/opt/app-root/lib/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/opt/app-root/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/opt/app-root/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/opt/app-root/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/opt/app-root/src/noggin/controller/password.py", line 163, in forgot_password_ask
mailer.send(email)
File "/opt/app-root/lib/python3.6/site-packages/flask_mail.py", line 492, in send
message.send(connection)
File "/opt/app-root/lib/python3.6/site-packages/flask_mail.py", line 427, in send
connection.send(self)
File "/opt/app-root/lib/python3.6/site-packages/flask_mail.py", line 192, in send
message.rcpt_options)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/smtplib.py", line 881, in sendmail
raise SMTPRecipientsRefused(senderrs)
smtplib.SMTPRecipientsRefused: {'username@domain': (550, b'5.1.1 <username@domain>: Recipient address rejected: User unknown in local recipient table')}
Hey @abompard I'd like to work on this! Would the best thing be to remove all the stack traces and just output something like "550 error, User not found?" Also did you mean to say 550 error not 500?
Hey! Sorry for not replying, are you still interested in this?