Skip to content

Commit

Permalink
fix: update login method
Browse files Browse the repository at this point in the history
  • Loading branch information
jensk-dev committed Nov 13, 2024
1 parent 78a1a94 commit 09c4e35
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,23 @@ async fn login_qbittorrent(
];

debug!("Attempting to authenticate with qBittorrent");
let response = client.post(&login_url).form(&params).send().await?;

let text = response.text().await?;
let response = client
.post(&login_url)
.header("Referer", qbittorrent_url)
.form(&params)
.send()
.await?;

if text != "Ok." {
if response.status().is_success() {
debug!("Authentication successful with qBittorrent");
Ok(())
} else if response.status().as_u16() == 403 {
error!("Authentication failed with qBittorrent: User's IP is banned for too many failed login attempts");
Err("Authentication failed with qBittorrent: User's IP is banned for too many failed login attempts".into())
} else {
error!("Authentication failed with qBittorrent");
return Err(
"Failed to authenticate to qBittorrent. Please check your credentials and URL.".into(),
);
Err("Failed to authenticate to qBittorrent. Please check your credentials and URL.".into())
}

Ok(())
}

/// Retrieves the current listening port from qBittorrent.
Expand Down

0 comments on commit 09c4e35

Please sign in to comment.