mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-04-02 18:31:50 -04:00
feat: gpauth support macos
This commit is contained in:
parent
81c5a6160c
commit
bc48a2f12e
@ -1,10 +1,8 @@
|
|||||||
use std::sync::Arc;
|
use std::{borrow::Cow, sync::Arc};
|
||||||
|
|
||||||
use gpapi::utils::redact::redact_uri;
|
use gpapi::utils::redact::redact_uri;
|
||||||
use log::warn;
|
use log::warn;
|
||||||
use webkit2gtk::{
|
use webkit2gtk::{gio::Cancellable, glib::GString, LoadEvent, URIResponseExt, WebResource, WebResourceExt, WebViewExt};
|
||||||
gio::Cancellable, glib::GString, LoadEvent, URIResponseExt, WebResource, WebResourceExt, WebView, WebViewExt,
|
|
||||||
};
|
|
||||||
use wry::WebViewExtUnix;
|
use wry::WebViewExtUnix;
|
||||||
|
|
||||||
use crate::webview::auth_messenger::AuthError;
|
use crate::webview::auth_messenger::AuthError;
|
||||||
@ -29,11 +27,16 @@ impl AuthResponse {
|
|||||||
|
|
||||||
pub fn get_body<F>(&self, cb: F)
|
pub fn get_body<F>(&self, cb: F)
|
||||||
where
|
where
|
||||||
F: FnOnce(anyhow::Result<Vec<u8>>) + 'static,
|
F: FnOnce(anyhow::Result<Option<Cow<'_, str>>>) + 'static,
|
||||||
{
|
{
|
||||||
let cancellable = Cancellable::NONE;
|
let cancellable = Cancellable::NONE;
|
||||||
self.web_resource.data(cancellable, move |data| {
|
self.web_resource.data(cancellable, move |data| {
|
||||||
cb(data.map_err(|e| anyhow::anyhow!(e)));
|
let body = data
|
||||||
|
.map_err(|e| anyhow::anyhow!(e))
|
||||||
|
.map(|data| String::from_utf8_lossy(&data).into_owned())
|
||||||
|
.map(|data| Some(Cow::Owned(data)));
|
||||||
|
|
||||||
|
cb(body);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user