Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
yuezk committed Jan 29, 2024
1 parent 9bc0994 commit 8860efa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ The project depends on `openconnect >= 8.20`, `webkit2gtk`, `libsecret`, `libaya

## About Trial

The CLI version is always free, while the GUI version is paid. There two trial modes for the GUI version:
The CLI version is always free, while the GUI version is paid. There are two trial modes for the GUI version:

1. 10-day trial: You can use the GUI stable release for 10 days after the installation.
2. 14-day trial: Each beta release has a fresh trial period (at most 14 days) after released.
Expand Down
8 changes: 5 additions & 3 deletions crates/gpapi/src/process/auth_launcher.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::process::Stdio;

use anyhow::bail;
use tokio::process::Command;

use crate::{auth::SamlAuthResult, credential::Credential, GP_AUTH_BINARY};
Expand Down Expand Up @@ -129,12 +130,13 @@ impl<'a> SamlAuthLauncher<'a> {
.wait_with_output()
.await?;

let auth_result = serde_json::from_slice::<SamlAuthResult>(&output.stdout)
.map_err(|_| anyhow::anyhow!("Failed to parse auth data"))?;
let Ok(auth_result) = serde_json::from_slice::<SamlAuthResult>(&output.stdout) else {
bail!("Failed to parse auth data")
};

match auth_result {
SamlAuthResult::Success(auth_data) => Credential::try_from(auth_data),
SamlAuthResult::Failure(msg) => Err(anyhow::anyhow!(msg)),
SamlAuthResult::Failure(msg) => bail!(msg),
}
}
}

0 comments on commit 8860efa

Please sign in to comment.