From: Ian Jackson Date: Fri, 30 Oct 2020 18:52:58 +0000 (+0000) Subject: wip new accounts X-Git-Tag: otter-0.2.0~580 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=184203bf381267927d44c26404fc171419a6a48f;p=otter.git wip new accounts Signed-off-by: Ian Jackson --- diff --git a/src/accounts.rs b/src/accounts.rs index 23928e35..62724e03 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -188,10 +188,6 @@ impl From> for AccessRecord { // xxx load, incl reveleation expiry // xxx periodic token reveleation expiry -pub fn save_accounts_now(_: &AccountsGuard) -> Result<(), InternalError> { - panic!("xxx") -} - trait AccountNameOrId : Copy { fn initial_lookup(self, accounts: &Accounts) -> Option; } @@ -277,13 +273,13 @@ impl AccountsGuard { { let (entry, acctid) = self.lookup_mut_caller_must_save(key, auth)?; - if let Some(new_access) = set_access() { + if let Some(new_access) = set_access { process_all_players_for_account(acctid, InstanceGuard::invalidate_tokens)?; - entry.access = new_access; + entry.access = AccessRecord(new_access); } let output = f(&mut *entry, acctid); - let ok = save_accounts_now(); + let ok = self.save_accounts_now(); match ok { Ok(()) => Ok(output), Err(e) => Err((e, output)) @@ -296,7 +292,7 @@ impl AccountsGuard { _auth: Authorisation) { use hash_map::Entry::*; - let accounts = self.get_or_insert_with(default); + let accounts = self.0.get_or_insert_with(default); let name_entry = accounts.names.entry(new_record.account.clone()); if_chain!{ if let Occupied(oe) = name_entry; @@ -312,7 +308,7 @@ impl AccountsGuard { } } } - save_accounts_now()?; + self.save_accounts_now()?; } #[throws(MgmtError)] @@ -331,7 +327,11 @@ impl AccountsGuard { process_all_players_for_account(acctid, InstanceGuard::player_remove)?; oe.remove(); accounts.records.remove(acctid); - save_accounts_now()?; + self.save_accounts_now()?; + } + + pub fn save_accounts_now(&self) -> Result<(), InternalError> { + panic!("xxx") } }