Add oauth util to check for existence of session by user_id.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -2,6 +2,7 @@ pub mod association;
|
|||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
iter::once,
|
iter::once,
|
||||||
|
pin::pin,
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
time::SystemTime,
|
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
|
/// Fetch database state for a session from its associated `(iss,sub)`, in case
|
||||||
/// `sess_id` is not known.
|
/// `sess_id` is not known.
|
||||||
#[implement(Sessions)]
|
#[implement(Sessions)]
|
||||||
|
|||||||
Reference in New Issue
Block a user