From 5911831acd96719640944b47c11e868ef4509aeb Mon Sep 17 00:00:00 2001 From: YinMo19 Date: Fri, 3 Jan 2025 11:02:40 +0800 Subject: [PATCH] [enhance] add return status judge. --- examples/req_auth.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/req_auth.rs b/examples/req_auth.rs index f408568..786001d 100644 --- a/examples/req_auth.rs +++ b/examples/req_auth.rs @@ -72,13 +72,18 @@ async fn main() -> Result<(), Box> { } } - let _response = client + let response = client .post("https://sso.hitsz.edu.cn:7002/cas/oauth2.0/authorize") .form(&form_data) .send() .await?; - println!("{}", "Login success.".green().bold()); + if response.status().is_success() { + println!("{}", "Login success.".green().bold()); + } else { + println!("{}", "Login failed.".red().bold()); + return Ok(()); + } // auth end. if args.json {