chiark / gitweb /
Do not reset access tokens (ie, invalidate urls) if access is the same
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 13 Jan 2021 21:36:24 +0000 (21:36 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 13 Jan 2021 21:36:24 +0000 (21:36 +0000)
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 <ijackson@chiark.greenend.org.uk>
src/accounts.rs

index bbf2a6d0f147fc263a4da83411e79b09d80d73aa..641a231c57285a9806dd2a628512d74277349d6d 100644 (file)
@@ -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();