def METHOD_NAME(self, username, password):
    """
    Authenticate the user, allowing the user to identify themselves either
    by username or email
    """
    authenticated_user = authenticate(username=username, password=password)
    if authenticated_user is None:
        UserModel = get_user_model()  # pylint: disable=invalid-name
        try:
            email_user = UserModel.objects.get(email=username)
        except UserModel.DoesNotExist:
            authenticated_user = None
        else:
            authenticated_user = authenticate(username=email_user.username, password=password)
    return authenticated_user