From: Ian Jackson Date: Tue, 20 Oct 2020 18:22:40 +0000 (+0100) Subject: wip new account etc. X-Git-Tag: otter-0.2.0~616 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=170d039795f6d9d87458938efbe7187268c24c7e;p=otter.git wip new account etc. Signed-off-by: Ian Jackson --- diff --git a/src/cmdlistener.rs b/src/cmdlistener.rs index a725dae1..f74f7255 100644 --- a/src/cmdlistener.rs +++ b/src/cmdlistener.rs @@ -77,9 +77,10 @@ fn execute(cs: &mut CommandStream, cmd: MgmtCommand) -> MgmtResponse { }; let gref = Instance::new(game, gs, authorised)?; - let mut ig = gref.lock()?; + let ig = gref.lock()?; - execute_for_game(cs, &mut ig, insns, MgmtGameUpdateMode::Bulk) + execute_for_game(cs, &mut Unauthorised::of(ig), + insns, MgmtGameUpdateMode::Bulk) .map_err(|e|{ let name = ig.name.clone(); Instance::destroy_game(ig, authorised) @@ -94,13 +95,15 @@ fn execute(cs: &mut CommandStream, cmd: MgmtCommand) -> MgmtResponse { }, ListGames { all } => { - let (scope, authorised) = if all == Some(true) { + let (scope, auth) = if all == Some(true) { let auth = authorise_scope(cs, &AS::Server)?; (None, auth) } else { - cs.current_account()?; + let (account, auth) = cs.account.as_ref() + .ok_or(ME::SpecifyAccount)?; + (Some(&account.scope), *auth) }; - let mut games = Instance::list_names(scope, authorised); + let mut games = Instance::list_names(scope, auth); games.sort_unstable(); GamesList(games) }, @@ -128,7 +131,8 @@ type ExecuteGameInsnResults = ( #[throws(ME)] fn execute_game_insn(cs: &CommandStream, - ig: &mut InstanceGuard, update: MgmtGameInstruction) + ig: &mut Unauthorised, + update: MgmtGameInstruction) -> ExecuteGameInsnResults { type U = ExecuteGameChangeUpdates; use MgmtGameInstruction::*; @@ -304,7 +308,8 @@ fn execute_game_insn(cs: &CommandStream, // ---------- how to execute game commands & handle their updates ---------- #[throws(ME)] -fn execute_for_game(cs: &CommandStream, ig: &mut InstanceGuard, +fn execute_for_game(cs: &CommandStream, + ig: &mut Unauthorised, mut insns: Vec, how: MgmtGameUpdateMode) -> MgmtResponse { let mut uh = UpdateHandler::from_how(how); @@ -416,7 +421,7 @@ impl UpdateHandler { struct CommandStream<'d> { euid : Result, desc : &'d str, - account : Option<(AccountName, Authorisation)>, + account : Option<(AccountName, Authorisation)>, chan : MgmtChannel, who: Who, }