mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 14:31:57 -05:00
Use new email validation.
Use logger.exception where it makes sense, not for SqlAlchemy errors as it give too much information away.
This commit is contained in:
@@ -197,7 +197,7 @@ def send_sms_code(encrypted_verification):
|
||||
try:
|
||||
firetext_client.send_sms(verification_message['to'], verification_message['secret_code'])
|
||||
except FiretextClientException as e:
|
||||
current_app.logger.error(e)
|
||||
current_app.logger.exception(e)
|
||||
|
||||
|
||||
@notify_celery.task(name='send-email-code')
|
||||
@@ -209,7 +209,7 @@ def send_email_code(encrypted_verification_message):
|
||||
"Verification code",
|
||||
verification_message['secret_code'])
|
||||
except AwsSesClientException as e:
|
||||
current_app.logger.error(e)
|
||||
current_app.logger.exception(e)
|
||||
|
||||
|
||||
# TODO: when placeholders in templates work, this will be a real template
|
||||
@@ -251,7 +251,7 @@ def email_invited_user(encrypted_invitation):
|
||||
subject_line,
|
||||
invitation_content)
|
||||
except AwsSesClientException as e:
|
||||
current_app.logger.error(e)
|
||||
current_app.logger.exception(e)
|
||||
|
||||
|
||||
def password_reset_message(name, url):
|
||||
@@ -274,4 +274,4 @@ def email_reset_password(encrypted_reset_password_message):
|
||||
password_reset_message(name=reset_password_message['name'],
|
||||
url=reset_password_message['reset_password_url']))
|
||||
except AwsSesClientException as e:
|
||||
current_app.logger.error(e)
|
||||
current_app.logger.exception(e)
|
||||
|
||||
@@ -41,7 +41,7 @@ def register_errors(blueprint):
|
||||
@blueprint.app_errorhandler(500)
|
||||
def internal_server_error(e):
|
||||
if isinstance(e, str):
|
||||
current_app.logger.error(e)
|
||||
current_app.logger.exception(e)
|
||||
elif isinstance(e, Exception):
|
||||
current_app.logger.exception(e)
|
||||
return jsonify(result='error', message="Internal server error"), 500
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import re
|
||||
from flask_marshmallow.fields import fields
|
||||
from . import ma
|
||||
from . import models
|
||||
from app.dao.permissions_dao import permission_dao
|
||||
from marshmallow import (post_load, ValidationError, validates, validates_schema)
|
||||
from marshmallow import (post_load, ValidationError, validates)
|
||||
from marshmallow_sqlalchemy import field_for
|
||||
from utils.recipients import (
|
||||
validate_email_address, InvalidEmailError,
|
||||
@@ -202,8 +201,10 @@ class EmailDataSchema(ma.Schema):
|
||||
email = fields.Str(required=False)
|
||||
|
||||
@validates('email')
|
||||
def validate_to(self, value):
|
||||
if not email_regex.match(value):
|
||||
def validate_email(self, value):
|
||||
try:
|
||||
validate_email_address(value)
|
||||
except InvalidEmailError:
|
||||
raise ValidationError('Invalid email')
|
||||
|
||||
user_schema = UserSchema()
|
||||
|
||||
Reference in New Issue
Block a user