diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2024-09-29 02:02:41 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2024-09-29 02:04:01 -0400 |
| commit | 6c054c5b8d43a818ccfa9087960dc19b286e6bb7 (patch) | |
| tree | c1eff6f13a1ac3ba102fcfa22de9f25ed30546d0 /src/repo/token.rs | |
| parent | 0b1cb80dd0b0f90c4892de7e7a2d18a076ecbdf2 (diff) | |
Reimplement the logout machinery in terms of token IDs, not token secrets.
This (a) reduces the amount of passing secrets around that's needed, and (b) allows tests to log out in a more straightforwards manner.
Ish. The fixtures are a mess, but so is the nomenclature. Fix the latter and the former will probably follow.
Diffstat (limited to 'src/repo/token.rs')
| -rw-r--r-- | src/repo/token.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/repo/token.rs b/src/repo/token.rs index 5f39e1d..d96c094 100644 --- a/src/repo/token.rs +++ b/src/repo/token.rs @@ -48,20 +48,20 @@ impl<'c> Tokens<'c> { } // Revoke a token by its secret. - pub async fn revoke(&mut self, secret: &IdentitySecret) -> Result<Id, sqlx::Error> { - let token = sqlx::query_scalar!( + pub async fn revoke(&mut self, token: &Id) -> Result<(), sqlx::Error> { + sqlx::query_scalar!( r#" delete from token - where secret = $1 + where id = $1 returning id as "id: Id" "#, - secret, + token, ) .fetch_one(&mut *self.0) .await?; - Ok(token) + Ok(()) } // Expire and delete all tokens that haven't been used more recently than |
