diff --git a/src/application/authentication.rs b/src/application/authentication.rs index 6f77162..1d80863 100644 --- a/src/application/authentication.rs +++ b/src/application/authentication.rs @@ -105,7 +105,7 @@ impl< now + Duration::from_secs(60 * 60 * 24 * 7), ) .await?; - self.token_repository.delete_later_than(now).await?; + self.token_repository.delete_earlier_than(now).await?; Ok(Response::Success { user_id, @@ -145,7 +145,7 @@ impl< now + Duration::from_secs(60 * 60 * 24 * 7), ) .await?; - self.token_repository.delete_later_than(now).await?; + self.token_repository.delete_earlier_than(now).await?; Ok(Response::Success { user_id, @@ -156,7 +156,7 @@ impl< async fn relogin(&self, token: &str) -> Result { self.token_repository - .delete_later_than(SystemTime::now()) + .delete_earlier_than(SystemTime::now()) .await?; let Some(user_id) = self.token_repository.get_user_id(token).await? else { diff --git a/src/persistence/token.rs b/src/persistence/token.rs index 292a3c2..4a05722 100644 --- a/src/persistence/token.rs +++ b/src/persistence/token.rs @@ -14,7 +14,7 @@ pub trait TokenRepository { user_id: i64, expires_at: SystemTime, ) -> Result<(), Error>; - async fn delete_later_than(&self, deadline: SystemTime) -> Result<(), Error>; + async fn delete_earlier_than(&self, deadline: SystemTime) -> Result<(), Error>; async fn get_user_id(&self, token: &str) -> Result, Error>; async fn get_all(&self) -> Result, Error>; async fn clear(&self) -> Result<(), Error>; @@ -54,8 +54,8 @@ impl TokenRepository for SqliteTokenRepository { .map(|_| ()) } - async fn delete_later_than(&self, deadline: SystemTime) -> Result<(), Error> { - query("DELETE FROM tokens WHERE expires_at > ?") + async fn delete_earlier_than(&self, deadline: SystemTime) -> Result<(), Error> { + query("DELETE FROM tokens WHERE expires_at < ?") .bind(deadline.duration_since(UNIX_EPOCH).unwrap().as_secs() as i64) .execute(self.pool.as_ref()) .await