def METHOD_NAME(self, username_or_email):
    """
    Fetch a user by data provided in the login field.
    This searches for a user by username in the default authority, or by
    email in the default authority if `username_or_email` contains an "@"
    character.
    When fetching by an email address we use a case-insensitive query.
    :returns: A user object if a user was found, None otherwise.
    :rtype: h.models.User or NoneType
    :raises UserNotActivated: When the user is not activated.
    """
    filters = [(User.authority == self.default_authority)]
    if "@" in username_or_email:
        filters.append(sa.func.lower(User.email) == username_or_email.lower())
    else:
        filters.append(User.username == username_or_email)
    user = self.session.query(User).filter(*filters).one_or_none()
    if user is None:
        return None
    if not user.is_activated:
        raise UserNotActivated()
    return user