Skip to content

Commit aae34e9

Browse files
committed
validate account credentials
1 parent 084e450 commit aae34e9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

ntfy-daemon/src/system_client.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,12 +485,25 @@ impl system_notifier::Server for SystemNotifier {
485485
mut results: system_notifier::AddAccountResults,
486486
) -> capnp::capability::Promise<(), capnp::Error> {
487487
let keyring = self.env.keyring.clone();
488+
let http = self.env.http.clone();
488489
Promise::from_future(async move {
489490
let account = params.get()?.get_account()?;
490491
let username = account.get_username()?.to_str()?;
491492
let server = account.get_server()?.to_str()?;
492493
let password = params.get()?.get_password()?.to_str()?;
493494

495+
info!("validating account");
496+
let url = models::Subscription::build_url(server, "stats", 0)
497+
.map_err(|e| capnp::Error::failed(e.to_string()))?;
498+
499+
http.get(url)
500+
.basic_auth(username, Some(password))
501+
.send()
502+
.await
503+
.map_err(|e| capnp::Error::failed(e.to_string()))?
504+
.error_for_status()
505+
.map_err(|e| capnp::Error::failed(e.to_string()))?;
506+
494507
let attrs = HashMap::from([
495508
("type", "password"),
496509
("username", username),

0 commit comments

Comments
 (0)