mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 06:24:23 +01:00
Show admins the email server error message when email sending fails (#2073)
* Show admins the email server error message when email sending fails
This commit is contained in:
@@ -477,4 +477,10 @@ class UserEmails(Resource):
|
||||
|
||||
result, response = sendmail(addr=user.email, text=text)
|
||||
|
||||
return {"success": result}
|
||||
if result is True:
|
||||
return {"success": True}
|
||||
else:
|
||||
return (
|
||||
{"success": False, "errors": {"": [response]}},
|
||||
400,
|
||||
)
|
||||
|
||||
@@ -894,7 +894,9 @@ def test_api_user_send_email():
|
||||
r = admin.post(
|
||||
"/api/v1/users/2/email", json={"text": "email should be accepted"}
|
||||
)
|
||||
assert r.status_code == 200
|
||||
# Email should go through but since we aren't mocking
|
||||
# the server we get a Connection refused error
|
||||
assert r.status_code == 400
|
||||
|
||||
destroy_ctfd(app)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user