summaryrefslogtreecommitdiff
path: root/src/login/app.rs
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2024-09-29 02:02:41 -0400
committerOwen Jacobson <owen@grimoire.ca>2024-09-29 02:04:01 -0400
commit6c054c5b8d43a818ccfa9087960dc19b286e6bb7 (patch)
treec1eff6f13a1ac3ba102fcfa22de9f25ed30546d0 /src/login/app.rs
parent0b1cb80dd0b0f90c4892de7e7a2d18a076ecbdf2 (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/login/app.rs')
-rw-r--r--src/login/app.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/login/app.rs b/src/login/app.rs
index b8916a8..182c62c 100644
--- a/src/login/app.rs
+++ b/src/login/app.rs
@@ -120,16 +120,13 @@ impl<'a> Logins<'a> {
Ok(())
}
- pub async fn logout(&self, secret: &IdentitySecret) -> Result<(), ValidateError> {
+ pub async fn logout(&self, token: &token::Id) -> Result<(), ValidateError> {
let mut tx = self.db.begin().await?;
- let token = tx
- .tokens()
- .revoke(secret)
- .await
- .not_found(|| ValidateError::InvalidToken)?;
+ tx.tokens().revoke(token).await?;
tx.commit().await?;
- self.logins.broadcast(&types::TokenRevoked::from(token));
+ self.logins
+ .broadcast(&types::TokenRevoked::from(token.clone()));
Ok(())
}