<commit_before>from social.exceptions import InvalidEmail
from social.pipeline.partial import partial


@partial
def mail_validation(strategy, details, *args, **kwargs):
    if details.get('email'):
        data = strategy.request_data()
        if 'code' in data:
            strategy.session_pop('email_validation_address')
            if not strategy.validate_email(details['email'], data['code']):
                raise InvalidEmail(strategy.backend)
        elif strategy.backend.REQUIRES_EMAIL_VALIDATION or \<commit_msg>Email validation only on new accounts<commit_after>from social.exceptions import InvalidEmail
from social.pipeline.partial import partial


@partial
def mail_validation(strategy, details, user=None, *args, **kwargs):
    if user is None and details.get('email'):
        data = strategy.request_data()
        if 'code' in data:
            strategy.session_pop('email_validation_address')
            if not strategy.validate_email(details['email'], data['code']):
                raise InvalidEmail(strategy.backend)
        elif strategy.backend.REQUIRES_EMAIL_VALIDATION or \
{'fraction_non_alphanumeric': 0.09764918625678119, 'fraction_numerical': 0.0, 'mean_word_length': 3.6317991631799162, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2064060', 'n_tokens_mistral': 288, 'n_tokens_neox': 290, 'n_words': 74}