From 0420f527c58f7336bdb885e0821b11e7f298a087 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 4 Mar 2026 17:05:42 +0000 Subject: [PATCH] Add oauth util to check for existence of session by user_id. Signed-off-by: Jason Volk --- src/service/oauth/sessions.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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)]