mirror of
https://github.com/FliegendeWurst/KIT-ILIAS-downloader.git
synced 2024-08-28 04:04:18 +00:00
Prompt user for username and password
This commit is contained in:
parent
f10bba3e3e
commit
e424ff6a72
18
Cargo.lock
generated
18
Cargo.lock
generated
@ -10,6 +10,8 @@ dependencies = [
|
||||
"parking_lot",
|
||||
"regex",
|
||||
"reqwest",
|
||||
"rpassword",
|
||||
"rprompt",
|
||||
"scraper",
|
||||
"serde_json",
|
||||
"structopt",
|
||||
@ -1243,6 +1245,22 @@ dependencies = [
|
||||
"winreg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rpassword"
|
||||
version = "4.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99371657d3c8e4d816fb6221db98fa408242b0b53bac08f8676a41f8554fe99f"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi 0.3.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rprompt"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b386f4748bdae2aefc96857f5fda07647f851d089420e577831e2a14b45230f8"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.16"
|
||||
|
@ -19,3 +19,5 @@ regex = "1.3.7"
|
||||
lazy_static = "1.4.0"
|
||||
parking_lot = "0.10.2"
|
||||
structopt = "0.3.13"
|
||||
rpassword = "4.0.5"
|
||||
rprompt = "1.0.5"
|
||||
|
@ -26,6 +26,7 @@ const ILIAS_URL: &'static str = "https://ilias.studium.kit.edu/";
|
||||
|
||||
struct ILIAS {
|
||||
opt: Opt,
|
||||
// TODO: use these for re-authentication in case of session timeout/invalidation
|
||||
user: String,
|
||||
pass: String,
|
||||
path_prefix: PathBuf,
|
||||
@ -226,7 +227,7 @@ impl ILIAS {
|
||||
login_soup = BeautifulSoup(otp_response.text, 'lxml')
|
||||
*/
|
||||
let saml = Selector::parse(r#"input[name="SAMLResponse"]"#).unwrap();
|
||||
let saml = dom.select(&saml).next().expect("no SAML response");
|
||||
let saml = dom.select(&saml).next().expect("no SAML response, incorrect password?");
|
||||
let relay_state = Selector::parse(r#"input[name="RelayState"]"#).unwrap();
|
||||
let relay_state = dom.select(&relay_state).next().expect("no relay state");
|
||||
println!("Logging into ILIAS..");
|
||||
@ -287,7 +288,9 @@ async fn main() {
|
||||
*TASKS_RUNNING.lock() -= 1;
|
||||
PANIC_HOOK.lock()(info);
|
||||
}));
|
||||
let mut ilias = match ILIAS::login::<&str, &str>(opt, env!("ILIAS_USER"), env!("ILIAS_PASS")).await {
|
||||
let user = rprompt::prompt_reply_stdout("Username: ").unwrap();
|
||||
let pass = rpassword::read_password_from_tty(Some("Password: ")).unwrap();
|
||||
let mut ilias = match ILIAS::login::<_, String>(opt, user, pass).await {
|
||||
Ok(ilias) => ilias,
|
||||
Err(e) => panic!("error: {:?}", e)
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user