Пример #1
0
def _validate_email_doesnt_exist(email):
    """Validate that the email is not associated with an existing user.

    :param email: The proposed email (unicode).
    :return: None
    :raises: errors.AccountEmailAlreadyExists
    """
    if email is not None and email_exists_or_retired(email):
        raise errors.AccountEmailAlreadyExists(_(accounts.EMAIL_CONFLICT_MSG).format(email_address=email))
Пример #2
0
def _validate_secondary_email_doesnt_exist(email):
    """Validate that the email is not associated as a secondary email of an existing user.

    :param email: The proposed email (unicode).
    :return: None
    :raises: errors.AccountEmailAlreadyExists
    """
    if email is not None and UserProfile.objects.filter(
            secondary_email=email).exists():
        # pylint: disable=no-member
        raise errors.AccountEmailAlreadyExists(
            accounts.EMAIL_CONFLICT_MSG.format(email_address=email))
Пример #3
0
def _validate_email_doesnt_exist(email, api_version='v1'):
    """Validate that the email is not associated with an existing user.

    :param email: The proposed email (unicode).
    :param api_version: Validation API version; it is used to determine the error message
    :return: None
    :raises: errors.AccountEmailAlreadyExists
    """
    if api_version == 'v1':
        error_message = accounts.EMAIL_CONFLICT_MSG.format(email_address=email)
    else:
        error_message = accounts.AUTHN_EMAIL_CONFLICT_MSG

    if email is not None and email_exists_or_retired(email):
        raise errors.AccountEmailAlreadyExists(_(error_message))  # lint-amnesty, pylint: disable=translation-of-non-string
Пример #4
0
def _validate_secondary_email_doesnt_exist(email):
    """
    Validate that the email is not associated as a secondary email of an existing user.

    Arguments:
        email (unicode): The proposed email.

    Returns:
        None

    Raises:
        errors.AccountEmailAlreadyExists: Raised if given email address is already associated as another
            user's secondary email.
    """
    if email is not None and AccountRecovery.objects.filter(secondary_email=email).exists():
        # pylint: disable=no-member
        raise errors.AccountEmailAlreadyExists(accounts.EMAIL_CONFLICT_MSG.format(email_address=email))