def login(self): response = self.loadPage( self.url["base"], self.url["login"], "GET", {"oauth_token": self.tmpOAuthToken}, ) # parse hpts and hptsh from page content hpts = re.search('.*\("hpts"\)\.value.*?"(.*?)"', response.data) hptsh = re.search('.*\("hptsh"\)\.value.*?"(.*?)"', response.data) if response.status != 200: logging.error( "Unexpected response status " "on login 200 != %s", response.status ) tools.exitErr() if "JSESSIONID" not in self.cookies: logging.error("Not found value JSESSIONID in the response cookies") tools.exitErr() # get login/password self.username, self.password = out.GetUserCredentials() self.postData["login"]["username"] = self.username self.postData["login"]["password"] = self.password self.postData["login"]["targetUrl"] = self.url["oauth"] % self.tmpOAuthToken self.postData["login"]["hpts"] = hpts and hpts.group(1) or "" self.postData["login"]["hptsh"] = hptsh and hptsh.group(1) or "" response = self.loadPage( self.url["base"], self.url["login"] + ";jsessionid=" + self.cookies["JSESSIONID"], "POST", self.postData["login"], ) if not response.location and response.status == 200: if self.incorrectLogin < 3: out.preloader.stop() out.printLine("Sorry, incorrect login or password") out.preloader.setMessage("Authorize...") self.incorrectLogin += 1 return self.login() else: logging.error("Incorrect login or password") if not response.location: logging.error("Target URL was not found in the response on login") tools.exitErr() if response.status == 302: # the user has enabled two factor auth return self.handleTwoFactor() logging.debug("Success authorize, redirect to access page")
def login(self): response = self.loadPage(self.url['base'], self.url['login'], "GET", {'oauth_token': self.tmpOAuthToken}) # parse hpts and hptsh from page content hpts = re.search('.*\("hpts"\)\.value.*?"(.*?)"', response.data) hptsh = re.search('.*\("hptsh"\)\.value.*?"(.*?)"', response.data) if response.status != 200: logging.error("Unexpected response status " "on login 200 != %s", response.status) tools.exitErr() if 'JSESSIONID' not in self.cookies: logging.error("Not found value JSESSIONID in the response cookies") tools.exitErr() # get login/password self.username, self.password = out.GetUserCredentials() self.postData['login']['username'] = self.username self.postData['login']['password'] = self.password self.postData['login']['targetUrl'] = self.url['oauth'] % self.tmpOAuthToken self.postData['login']['hpts'] = hpts and hpts.group(1) or "" self.postData['login']['hptsh'] = hptsh and hptsh.group(1) or "" response = self.loadPage(self.url['base'], self.url['login'] + ";jsessionid=" + self.cookies['JSESSIONID'], "POST", self.postData['login']) if not response.location and response.status == 200: if self.incorrectLogin < 3: out.preloader.stop() out.printLine('Sorry, incorrect login or password') out.preloader.setMessage('Authorize...') self.incorrectLogin += 1 return self.login() else: logging.error("Incorrect login or password") if not response.location: logging.error("Target URL was not found in the response on login") tools.exitErr() # @todo response.status is always 302, regardless of whether TwoFactor is enabled # if response.status == 302: # # the user has enabled two factor auth # return self.handleTwoFactor() logging.debug("Success authorize, redirect to access page")
def login(self): response = self.loadPage(self.url['base'], self.url['login'], "GET", {'oauth_token': self.tmpOAuthToken}) if response.status != 200: logging.error("Unexpected response status " "on login 200 != %s", response.status) tools.exitErr() if 'JSESSIONID' not in self.cookies: logging.error("Not found value JSESSIONID in the response cookies") tools.exitErr() # get login/password self.username, self.password = out.GetUserCredentials() self.postData['login']['username'] = self.username self.postData['login']['password'] = self.password self.postData['login']['targetUrl'] = self.url['oauth'] % self.tmpOAuthToken response = self.loadPage(self.url['base'], self.url['login'] + ";jsessionid=" + self.cookies['JSESSIONID'], "POST", self.postData['login']) if not response.location and response.status == 200: if self.incorrectLogin < 3: out.preloader.stop() out.printLine('Sorry, incorrect login or password') out.preloader.setMessage('Authorize...') self.incorrectLogin += 1 return self.login() else: logging.error("Incorrect login or password") if not response.location: logging.error("Target URL was not found in the response on login") tools.exitErr() if response.status == 302: # the user has enabled two factor auth return self.handleTwoFactor() logging.debug("Success authorize, redirect to access page")