mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2024-11-20 03:39:17 +01:00
When run in non-TTY, attempt to recycle cookies and tokens if they exist.
This commit is contained in:
parent
43bca1f878
commit
6ba2a7d486
@ -255,21 +255,27 @@ int Downloader::login()
|
||||
else
|
||||
{
|
||||
if (!isatty(STDIN_FILENO)) {
|
||||
std::cerr << "Unable to read email and password" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
std::cerr << "Email: ";
|
||||
std::getline(std::cin,email);
|
||||
/* Attempt to read this stuff from elsewhere */
|
||||
bool cookie_gone = boost::filesystem::exists(Globals::globalConfig.curlConf.sCookiePath);
|
||||
bool tokens_gone = boost::filesystem::exists(Globals::globalConfig.sConfigDirectory + "/galaxy_tokens.json");
|
||||
if(cookie_gone || tokens_gone) {
|
||||
std::cerr << "Unable to read email and password" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
std::cerr << "Email: ";
|
||||
std::getline(std::cin,email);
|
||||
|
||||
std::cerr << "Password: ";
|
||||
struct termios termios_old, termios_new;
|
||||
tcgetattr(STDIN_FILENO, &termios_old); // Get current terminal attributes
|
||||
termios_new = termios_old;
|
||||
termios_new.c_lflag &= ~ECHO; // Set ECHO off
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &termios_new); // Set terminal attributes
|
||||
std::getline(std::cin, password);
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &termios_old); // Restore old terminal attributes
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "Password: ";
|
||||
struct termios termios_old, termios_new;
|
||||
tcgetattr(STDIN_FILENO, &termios_old); // Get current terminal attributes
|
||||
termios_new = termios_old;
|
||||
termios_new.c_lflag &= ~ECHO; // Set ECHO off
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &termios_new); // Set terminal attributes
|
||||
std::getline(std::cin, password);
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &termios_old); // Restore old terminal attributes
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (email.empty() || password.empty())
|
||||
|
Loading…
Reference in New Issue
Block a user