Skip to content

Commit 59e25c0

Browse files
committed
fixup! When consuming a compat refresh token, consume others in the session
1 parent 20671a9 commit 59e25c0

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/storage-pg/src/compat/refresh_token.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ impl CompatRefreshTokenRepository for PgCompatRefreshTokenRepository<'_> {
205205
UPDATE compat_refresh_tokens
206206
SET consumed_at = $2
207207
WHERE compat_session_id = $1
208+
AND consumed_at IS NULL
208209
"#,
209210
Uuid::from(compat_refresh_token.session_id),
210211
consumed_at,
@@ -213,7 +214,15 @@ impl CompatRefreshTokenRepository for PgCompatRefreshTokenRepository<'_> {
213214
.execute(&mut *self.conn)
214215
.await?;
215216

216-
DatabaseError::ensure_affected_rows(&res, 1)?;
217+
// This can affect multiple rows in case we've imported refresh tokens
218+
// from Synapse. What we care about is that it at least affected one,
219+
// which is what we're checking here
220+
if res.rows_affected() == 0 {
221+
return Err(DatabaseError::RowsAffected {
222+
expected: 1,
223+
actual: 0,
224+
});
225+
}
217226

218227
let compat_refresh_token = compat_refresh_token
219228
.consume(consumed_at)

0 commit comments

Comments
 (0)