server_url / server_pins: the configured sync server, for the apps' Settings
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -977,6 +977,17 @@ impl VaultCore {
|
||||
self.store.get_meta(META_SESSION).ok().flatten().is_some()
|
||||
}
|
||||
|
||||
/// The sync server this vault is configured with (`configure_server`, onboarding, sign-in), if any. The apps
|
||||
/// show it in Settings; the core's copy is the one that counts.
|
||||
pub fn server_url(&self) -> Option<String> {
|
||||
self.lock_inner().server.as_ref().map(|s| s.url.clone())
|
||||
}
|
||||
|
||||
/// The SPKI pins configured with [`Self::server_url`].
|
||||
pub fn server_pins(&self) -> Vec<String> {
|
||||
self.lock_inner().server.as_ref().map(|s| s.pins.clone()).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Deletes the account (docs/03 "Deleting the account"; required by the App Store and Google Play): on the
|
||||
/// sync server first when one is configured, then everything on this device. The master password is checked
|
||||
/// again, so an unlocked but unattended device can't do it. A server that can't be reached fails the whole
|
||||
|
||||
@@ -679,11 +679,14 @@ async fn sign_out_device_keeps_the_account_on_the_server() {
|
||||
|
||||
let a = VaultCore::open(path.clone()).unwrap();
|
||||
let sk = a.create_account(PW.into()).unwrap();
|
||||
assert_eq!(a.server_url(), None);
|
||||
connect(&a, &server);
|
||||
assert_eq!(a.server_url(), Some(server.url()));
|
||||
a.register_account(SETUP_TOKEN.into()).await.unwrap();
|
||||
let id = a.save_item(login_item("Bank", "pw-a")).unwrap(); // not synced yet: sign-out syncs it first
|
||||
a.sign_out_device(false).await.unwrap();
|
||||
assert!(!a.has_account() && !a.is_logged_in());
|
||||
assert_eq!(a.server_url(), None);
|
||||
|
||||
// Same device, signed in again: the item came back from the server.
|
||||
connect(&a, &server);
|
||||
|
||||
Reference in New Issue
Block a user