diff --git a/src/service/oauth/sessions.rs b/src/service/oauth/sessions.rs index 66bfe339..6eeeda97 100644 --- a/src/service/oauth/sessions.rs +++ b/src/service/oauth/sessions.rs @@ -2,6 +2,7 @@ pub mod association; use std::{ iter::once, + pin::pin, sync::{Arc, Mutex}, time::SystemTime, }; @@ -193,6 +194,17 @@ pub async fn put(&self, session: &Session) { } } +/// Check if database state exists for one or more sessions associated with +/// `user_id` +#[implement(Sessions)] +#[tracing::instrument(level = "debug", skip(self), ret(level = "debug"))] +pub async fn exists_for_user(&self, user_id: &UserId) -> bool { + pin!(self.get_by_user(user_id)) + .next() + .await + .is_some() +} + /// Fetch database state for a session from its associated `(iss,sub)`, in case /// `sess_id` is not known. #[implement(Sessions)]