Ejemplo n.º 1
0
    def require_phone_number(self, html, session):
        logger.info(
            'Auth requires phone number. You do login from unusual place')

        # Raises VkPageWarningsError in case of warnings
        # NOTE: we check only 'security_check' case on warnings for now
        # in future it might be propagated to other cases as well
        check_html_warnings(html=html)

        # Determine form action url
        action_url = parse_form_action_url(html)

        # Get masked phone from html to make things more clear
        phone_prefix, phone_suffix = parse_masked_phone_number(html)

        if self._phone_number:
            code = self._phone_number[len(phone_prefix):-len(phone_suffix)]
        else:
            prompt = 'Enter missing digits of your phone number (%s****%s): '\
                        % (phone_prefix, phone_suffix)
            code = raw_input(prompt)

        params = parse_url_query_params(action_url, fragment=False)
        auth_data = {
            'code': code,
            'act': 'security_check',
            'hash': params['hash']}
        response = session.post(
            url=self.LOGIN_URL + action_url, data=auth_data)
        logger.debug('require_phone_number resp: %s', response.text)
Ejemplo n.º 2
0
    def require_phone_number(self, html, session):
        logger.info(
            'Auth requires phone number. You do login from unusual place')

        # Raises VkPageWarningsError in case of warnings
        # NOTE: we check only 'security_check' case on warnings for now
        # in future it might be propagated to other cases as well
        check_html_warnings(html=html)

        # Determine form action url
        action_url = parse_form_action_url(html)

        # Get masked phone from html to make things more clear
        phone_prefix, phone_suffix = parse_masked_phone_number(html)

        if self._phone_number:
            code = self._phone_number[len(phone_prefix):-len(phone_suffix)]
        else:
            prompt = 'Enter missing digits of your phone number (%s****%s): '\
                        % (phone_prefix, phone_suffix)
            code = raw_input(prompt)

        params = parse_url_query_params(action_url, fragment=False)
        auth_data = {
            'code': code,
            'act': 'security_check',
            'hash': params['hash']
        }
        response = session.post(url=self.LOGIN_URL + action_url,
                                data=auth_data)
        logger.debug('require_phone_number resp: %s', response.text)
Ejemplo n.º 3
0
 def test_parse_masked_phone_number(self):
     html = get_fixture('require_phone_num_resp.html')
     fields = utils.parse_masked_phone_number(html)
     self.assertEqual(fields, ('+1234', '89'))
Ejemplo n.º 4
0
 def test_parse_masked_phone_number(self):
     html = get_fixture('require_phone_num_resp.html')
     fields = utils.parse_masked_phone_number(html)
     self.assertEqual(fields, ('+1234', '89'))