find_active_by_session: take &PersonalSession
This commit is contained in:
@@ -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?
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user