Skip to content

Commit

Permalink
Refactor login code
Browse files Browse the repository at this point in the history
Users can now get around reCATPCHA without the downloader being built with GUI enabled by using their browser to login
  • Loading branch information
Sude- committed Mar 12, 2023
1 parent 9e5e833 commit c26e28a
Show file tree
Hide file tree
Showing 3 changed files with 241 additions and 190 deletions.
6 changes: 6 additions & 0 deletions include/website.h
Expand Up @@ -33,6 +33,12 @@ class Website
bool IsLoggedInComplex(const std::string& email);
std::map<std::string, std::string> getTagsFromJson(const Json::Value& json);
int retries;
std::string LoginGetAuthCode(const std::string& email, const std::string& password);
std::string LoginGetAuthCodeCurl(const std::string& login_form_html, const std::string& email, const std::string& password);
std::string LoginGetAuthCodeBrowser(const std::string& auth_url);
#ifdef USE_QT_GUI_LOGIN
std::string LoginGetAuthCodeGUI(const std::string& email, const std::string& password);
#endif
};

#endif // WEBSITE_H
24 changes: 12 additions & 12 deletions src/downloader.cpp
Expand Up @@ -316,31 +316,31 @@ int Downloader::login()
if (!boost::filesystem::remove(Globals::globalConfig.curlConf.sCookiePath))
std::cerr << "Failed to delete " << Globals::globalConfig.curlConf.sCookiePath << std::endl;

int iWebsiteLoginResult = gogWebsite->Login(email, password);
if (iWebsiteLoginResult < 1)
{
std::cerr << "HTTP: Login failed" << std::endl;
return 0;
}
else
{
std::cerr << "HTTP: Login successful" << std::endl;
}
int iLoginResult = gogWebsite->Login(email, password);

if (iWebsiteLoginResult < 2)
if (iLoginResult < 1)
{
std::cerr << "Galaxy: Login failed" << std::endl;
return 0;
}
else
{
std::cerr << "Galaxy: Login successful" << std::endl;

if (!Globals::galaxyConf.getJSON().empty())
{
this->saveGalaxyJSON();
}
}

if (gogWebsite->IsLoggedIn())
{
std::cerr << "HTTP: Login successful" << std::endl;
}
else
{
std::cerr << "HTTP: Login failed" << std::endl;
return 0;
}
}
}
return 1;
Expand Down

0 comments on commit c26e28a

Please sign in to comment.