From: Ian Jackson Date: Wed, 13 Jan 2021 21:36:24 +0000 (+0000) Subject: Do not reset access tokens (ie, invalidate urls) if access is the same X-Git-Tag: otter-0.3.0~27 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=024af987520a416f9bbb93d048ac9f889dbdce52;p=otter.git Do not reset access tokens (ie, invalidate urls) if access is the same This means that if the user specifies an access option to `otter --join-game` they don't get thrown off if it was the same as before. Signed-off-by: Ian Jackson --- diff --git a/src/accounts.rs b/src/accounts.rs index bbf2a6d0..641a231c 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -321,12 +321,17 @@ impl AccountsGuard { let (entry, acctid) = self.lookup_mut_caller_must_save(key, auth)?; if let Some(new_access) = set_access { - process_all_players_for_account( - games, - acctid, - |ig, player| ig.invalidate_tokens(player) - )?; - entry.access = new_access; + if (|| Ok::<_,IE>( + rmp_serde::encode::to_vec(&new_access)? + != rmp_serde::encode::to_vec(&entry.access)? + ))()? { + process_all_players_for_account( + games, + acctid, + |ig, player| ig.invalidate_tokens(player) + )?; + entry.access = new_access; + } } let output = f(&mut *entry, acctid); let ok = self.save_accounts_now();