find_active_by_session: take &PersonalSession

This commit is contained in:
Olivier 'reivilibre
2025-10-21 09:43:46 +01:00
parent b4af9217ab
commit 2bf837257c
4 changed files with 7 additions and 7 deletions

View File

@@ -81,7 +81,7 @@ pub async fn handler(
None
} else {
repo.personal_access_token()
.find_active_for_session(session.id)
.find_active_for_session(&session)
.await?
};

View File

@@ -124,7 +124,7 @@ pub async fn handler(
// Revoke the existing active token for the session.
let old_token_opt = repo
.personal_access_token()
.find_active_for_session(session_id)
.find_active_for_session(&session)
.await?;
let Some(old_token) = old_token_opt else {
// This shouldn't happen

View File

@@ -138,7 +138,7 @@ impl PersonalAccessTokenRepository for PgPersonalAccessTokenRepository<'_> {
)]
async fn find_active_for_session(
&mut self,
session_id: Ulid,
session: &PersonalSession,
) -> Result<Option<PersonalAccessToken>, Self::Error> {
let res: Option<PersonalAccessTokenLookup> = sqlx::query_as!(
PersonalAccessTokenLookup,
@@ -154,7 +154,7 @@ impl PersonalAccessTokenRepository for PgPersonalAccessTokenRepository<'_> {
WHERE personal_session_id = $1
AND revoked_at IS NULL
"#,
Uuid::from(session_id),
Uuid::from(session.id),
)
.traced()
.fetch_optional(&mut *self.conn)

View File

@@ -56,14 +56,14 @@ pub trait PersonalAccessTokenRepository: Send + Sync {
///
/// # Parameters
///
/// * `session_id`: The ID of the session to lookup
/// * `session`: The session to lookup
///
/// # Errors
///
/// Returns [`Self::Error`] if the underlying repository fails
async fn find_active_for_session(
&mut self,
session_id: Ulid,
session: &PersonalSession,
) -> Result<Option<PersonalAccessToken>, Self::Error>;
/// Add a new access token to the database
@@ -120,7 +120,7 @@ repository_impl!(PersonalAccessTokenRepository:
async fn find_active_for_session(
&mut self,
session_id: Ulid,
session: &PersonalSession,
) -> Result<Option<PersonalAccessToken>, Self::Error>;
async fn add(