From 84ff3aa33e1b8829b4561ca3451ab4ab02472346 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 24 Oct 2020 01:02:33 +0100 Subject: [PATCH] wip new account etc., before consider account creation Signed-off-by: Ian Jackson --- src/accounts.rs | 17 ++++++++++++++++- src/cmdlistener.rs | 4 ++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/accounts.rs b/src/accounts.rs index 998b0e72..8540c47e 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -165,7 +165,7 @@ impl AccountRecord { ).ok() } pub fn lookup_mut_caller_must_save(account: &AccountName, - _: Authorisation) + _auth: Authorisation) -> Option> { RwLockWriteGuard::try_map( ACCOUNTS.write(), @@ -187,6 +187,21 @@ impl AccountRecord { } } + #[throws(MgmtError)] + pub fn insert_entry(account: AccountName, + _auth: Authorisation, + data: AccountRecord) + { + let entry = ACCOUNTS.write().unwrap_or_default().entry(account); + use hash_map::Entry::*; + let ve = match entry { + Occupied(_) => throw!(ME::AlreadyExists), + Vacant(ve) => ve, + }; + ve.insert(data); + save_accounts_now()?; + } + pub fn expire_tokens_revealed(&mut self) { panic!("xxx") } diff --git a/src/cmdlistener.rs b/src/cmdlistener.rs index 1e034c05..d5c2ce05 100644 --- a/src/cmdlistener.rs +++ b/src/cmdlistener.rs @@ -88,6 +88,10 @@ fn execute(cs: &mut CommandStream, cmd: MgmtCommand) -> MgmtResponse { Fine }, + CreateAccont(AccountDetails) => { + let authorised = authorise_for_account(cs, &game)?; + } + CreateGame { game, insns } => { let authorised = authorise_by_account(cs, &game)?; -- 2.30.2