Error on expired session

This commit is contained in:
FliegendeWurst 2021-05-30 14:05:29 +02:00
parent 8ea2cae769
commit daa9bdbfa4

View File

@ -184,6 +184,15 @@ impl ILIAS {
} }
pub async fn get_html(&self, url: &str) -> Result<Html> { pub async fn get_html(&self, url: &str) -> Result<Html> {
let resp = self.download(url).await?;
if resp
.url()
.query()
.map(|x| x.contains("reloadpublic=1") || x.contains("cmd=force_login"))
.unwrap_or(false)
{
return Err(anyhow!("not logged in / session expired"));
}
let text = self.download(url).await?.text().await?; let text = self.download(url).await?.text().await?;
let html = Html::parse_document(&text); let html = Html::parse_document(&text);
if html.select(&alert_danger).next().is_some() { if html.select(&alert_danger).next().is_some() {