'Authenticate the facebook user by id OR facebook_email
We filter using an OR to allow existing members to connect with
their facebook ID using email.
:param facebook_id:
Optional string representing the facebook id
:param facebook_email:
Optional string with the facebook email
:return: The signed in :class:`User`.'

def profile_authenticate(self, facebook_id=None, facebook_email=None):

    if (facebook_id or facebook_email):
        profile_class = get_profile_model()
        profile_query = profile_class.objects.all().order_by('user')
        profile_query = profile_query.select_related('user')
        profile = None
        if facebook_id:
            profiles = profile_query.filter(facebook_id=facebook_id)[:1]
            profile = (profiles[0] if profiles else None)
        if ((profile is None) and facebook_email):
            try:
                profiles = profile_query.filter(user__email__iexact=facebook_email)[:1]
                profile = (profiles[0] if profiles else None)
            except DatabaseError:
                try:
                    user = get_user_model().objects.get(email=facebook_email)
                except get_user_model().DoesNotExist:
                    user = None
                profile = (get_profile(user) if user else None)
        if profile:
            user = profile.user
            user._profile = profile
            if facebook_settings.FACEBOOK_FORCE_PROFILE_UPDATE_ON_LOGIN:
                user.fb_update_required = True
            return user
