|
27 | 27 | RE_LOGIN_HASH = re.compile(r'name="lg_h" value="([a-z0-9]+)"') |
28 | 28 | RE_CAPTCHAID = re.compile(r"onLoginCaptcha\('(\d+)'") |
29 | 29 | RE_NUMBER_HASH = re.compile(r"al_page: '3', hash: '([a-z0-9]+)'") |
30 | | -RE_AUTH_HASH = re.compile( |
31 | | - r"\{.*?act: 'a_authcheck_code'.+?hash: '([a-z_0-9]+)'.*?\}" |
32 | | -) |
| 30 | +RE_AUTH_HASH = re.compile(r"Authcheck\.init\('([a-z_0-9]+)'") |
33 | 31 | RE_TOKEN_URL = re.compile(r'location\.href = "(.*?)"\+addr;') |
34 | 32 |
|
35 | 33 | RE_PHONE_PREFIX = re.compile(r'label ta_r">\+(.*?)<') |
@@ -317,19 +315,28 @@ def _pass_twofactor(self, auth_response): |
317 | 315 |
|
318 | 316 | :param auth_response: страница с приглашением к аутентификации |
319 | 317 | """ |
320 | | - code, remember_device = self.error_handlers[TWOFACTOR_CODE]() |
321 | 318 |
|
322 | 319 | auth_hash = search_re(RE_AUTH_HASH, auth_response.text) |
323 | 320 |
|
| 321 | + if not auth_hash: |
| 322 | + raise TwoFactorError( |
| 323 | + 'Two factor authentication can not be passed:' |
| 324 | + ' could not find "hash" value. Please create a bugreport' |
| 325 | + ) |
| 326 | + |
| 327 | + code, remember_device = self.error_handlers[TWOFACTOR_CODE]() |
| 328 | + |
324 | 329 | values = { |
325 | | - 'act': 'a_authcheck_code', |
326 | 330 | 'al': '1', |
327 | 331 | 'code': code, |
328 | | - 'remember': int(remember_device), |
329 | 332 | 'hash': auth_hash, |
| 333 | + 'remember': int(remember_device), |
330 | 334 | } |
331 | 335 |
|
332 | | - response = self.http.post('https://vk.com/al_login.php', values) |
| 336 | + response = self.http.post( |
| 337 | + 'https://vk.com/al_login.php?act=a_authcheck_code', |
| 338 | + values |
| 339 | + ) |
333 | 340 | data = json.loads(response.text.lstrip('<!--')) |
334 | 341 | status = data['payload'][0] |
335 | 342 |
|
|
0 commit comments