def authenticate(self, site, site_url, assertion):
        """Verifies BrowserID assertion

        Returns:
             Object that represents a user with an email verified by
             the assertion. If a user with such email does not exists,
             but there are open locations that require login, the user
             object is created. In other cases, None is returned.

        Raises:
            AuthenticationError: verification failed.
        """
        try:
            result = self.verifier.verify(assertion=assertion,
                                          audience=site_url)
        except BrowserIDException as ex:
            return AuthenticationError(
                'Failed to contact Persona verification service')
        if not result:
            raise AuthenticationError(
                'BrowserID assertion verification failed.')
        user = site.users.find_item_by_email(result.email)
        if user is not None:
            return user
        try:
            # The site has open locations that require login, every
            # user needs to be allowed.
            #
            # TODO: user objects created in such way should probably
            # be marked and automatically deleted on logout or after
            # some time of inactivity.
            if site.locations.has_open_location_with_login():
                return site.users.create_item(result.email)
            else:
                return None
        except __HOLE__ as ex:
            raise AuthenticationError(', '.join(ex.messages))
        except LimitExceeded as ex:
            raise AuthenticationError(str(ex))
dataset/ETHPy150Open wrr/wwwhisper/wwwhisper_auth/backend.py/BrowserIDBackend.authenticate