chiark / gitweb /
wip new account etc., before consider account creation
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 24 Oct 2020 00:02:33 +0000 (01:02 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 24 Oct 2020 00:02:33 +0000 (01:02 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/accounts.rs
src/cmdlistener.rs

index 998b0e72a6ab706b4a50805044fc2311bfd83025..8540c47e39611f76e4a6f5ff26459d04ae3ef652 100644 (file)
@@ -165,7 +165,7 @@ impl AccountRecord {
     ).ok()
   }
   pub fn lookup_mut_caller_must_save(account: &AccountName,
-                                      _: Authorisation<AccountName>)
+                                      _auth: Authorisation<AccountName>)
             -> Option<MappedRwLockWriteGuard<'static, AccountRecord>> {
     RwLockWriteGuard::try_map(
       ACCOUNTS.write(),
@@ -187,6 +187,21 @@ impl AccountRecord {
     }
   }
 
+  #[throws(MgmtError)]
+  pub fn insert_entry<T, F>(account: AccountName,
+                            _auth: Authorisation<AccountName>,
+                            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")
   }
index 1e034c05a700555fd849bf1c0436c7fdf120b41b..d5c2ce05c6dc3757f6b8b7376f8e94fe6a247818 100644 (file)
@@ -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)?;