Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
Add message if stored login is expired
Browse files Browse the repository at this point in the history
  • Loading branch information
bytedream committed Apr 19, 2024
1 parent db6e45e commit 8fff807
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions crunchy-cli-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,19 @@ async fn crunchyroll_session(
if let Some((token_type, token)) = session.split_once(':') {
match token_type {
"refresh_token" => {
return Ok(builder.login_with_refresh_token(token).await?)
return match builder.login_with_refresh_token(token).await {
Ok(crunchy) => Ok(crunchy),
Err(e) => {
if let Error::Request { message, .. } = &e {
if message.starts_with("invalid_grant") {
bail!("The stored login is expired, please login again")
}
}
Err(e.into())
}
}
}
"etp_rt" => bail!("The stored login method (etp-rt) isn't supported anymore. Please use your credentials to login"),
"etp_rt" => bail!("The stored login method (etp-rt) isn't supported anymore. Please login again using your credentials"),
_ => (),
}
}
Expand Down

0 comments on commit 8fff807

Please sign in to comment.