validate account credentials
This commit is contained in:
@ -485,12 +485,25 @@ impl system_notifier::Server for SystemNotifier {
|
|||||||
mut results: system_notifier::AddAccountResults,
|
mut results: system_notifier::AddAccountResults,
|
||||||
) -> capnp::capability::Promise<(), capnp::Error> {
|
) -> capnp::capability::Promise<(), capnp::Error> {
|
||||||
let keyring = self.env.keyring.clone();
|
let keyring = self.env.keyring.clone();
|
||||||
|
let http = self.env.http.clone();
|
||||||
Promise::from_future(async move {
|
Promise::from_future(async move {
|
||||||
let account = params.get()?.get_account()?;
|
let account = params.get()?.get_account()?;
|
||||||
let username = account.get_username()?.to_str()?;
|
let username = account.get_username()?.to_str()?;
|
||||||
let server = account.get_server()?.to_str()?;
|
let server = account.get_server()?.to_str()?;
|
||||||
let password = params.get()?.get_password()?.to_str()?;
|
let password = params.get()?.get_password()?.to_str()?;
|
||||||
|
|
||||||
|
info!("validating account");
|
||||||
|
let url = models::Subscription::build_url(server, "stats", 0)
|
||||||
|
.map_err(|e| capnp::Error::failed(e.to_string()))?;
|
||||||
|
|
||||||
|
http.get(url)
|
||||||
|
.basic_auth(username, Some(password))
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
.map_err(|e| capnp::Error::failed(e.to_string()))?
|
||||||
|
.error_for_status()
|
||||||
|
.map_err(|e| capnp::Error::failed(e.to_string()))?;
|
||||||
|
|
||||||
let attrs = HashMap::from([
|
let attrs = HashMap::from([
|
||||||
("type", "password"),
|
("type", "password"),
|
||||||
("username", username),
|
("username", username),
|
||||||
|
|||||||
Reference in New Issue
Block a user