storage: introduce find_active_for_session for PATs

This commit is contained in:
Olivier 'reivilibre
2025-10-16 12:07:58 +01:00
parent 95f4c9a8e5
commit 46045d44bc
4 changed files with 105 additions and 1 deletions

View File

@@ -50,6 +50,22 @@ pub trait PersonalAccessTokenRepository: Send + Sync {
access_token: &str,
) -> Result<Option<PersonalAccessToken>, Self::Error>;
/// Find the active access token belonging to a given session.
///
/// Returns the active access token if it exists, `None` otherwise
///
/// # Parameters
///
/// * `session_id`: The ID of the session to lookup
///
/// # Errors
///
/// Returns [`Self::Error`] if the underlying repository fails
async fn find_active_for_session(
&mut self,
session_id: Ulid,
) -> Result<Option<PersonalAccessToken>, Self::Error>;
/// Add a new access token to the database
///
/// Returns the newly created access token
@@ -102,6 +118,11 @@ repository_impl!(PersonalAccessTokenRepository:
access_token: &str,
) -> Result<Option<PersonalAccessToken>, Self::Error>;
async fn find_active_for_session(
&mut self,
session_id: Ulid,
) -> Result<Option<PersonalAccessToken>, Self::Error>;
async fn add(
&mut self,
rng: &mut (dyn RngCore + Send),