Skip to content

Commit 78b010d

Browse files
committed
find_active_by_session: take &PersonalSession
1 parent 4863026 commit 78b010d

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

crates/handlers/src/admin/v1/personal_sessions/get.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub async fn handler(
8181
None
8282
} else {
8383
repo.personal_access_token()
84-
.find_active_for_session(session.id)
84+
.find_active_for_session(&session)
8585
.await?
8686
};
8787

crates/handlers/src/admin/v1/personal_sessions/regenerate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub async fn handler(
124124
// Revoke the existing active token for the session.
125125
let old_token_opt = repo
126126
.personal_access_token()
127-
.find_active_for_session(session_id)
127+
.find_active_for_session(&session)
128128
.await?;
129129
let Some(old_token) = old_token_opt else {
130130
// This shouldn't happen

crates/storage-pg/src/personal/access_token.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl PersonalAccessTokenRepository for PgPersonalAccessTokenRepository<'_> {
138138
)]
139139
async fn find_active_for_session(
140140
&mut self,
141-
session_id: Ulid,
141+
session: &PersonalSession,
142142
) -> Result<Option<PersonalAccessToken>, Self::Error> {
143143
let res: Option<PersonalAccessTokenLookup> = sqlx::query_as!(
144144
PersonalAccessTokenLookup,
@@ -154,7 +154,7 @@ impl PersonalAccessTokenRepository for PgPersonalAccessTokenRepository<'_> {
154154
WHERE personal_session_id = $1
155155
AND revoked_at IS NULL
156156
"#,
157-
Uuid::from(session_id),
157+
Uuid::from(session.id),
158158
)
159159
.traced()
160160
.fetch_optional(&mut *self.conn)

crates/storage/src/personal/access_token.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ pub trait PersonalAccessTokenRepository: Send + Sync {
5656
///
5757
/// # Parameters
5858
///
59-
/// * `session_id`: The ID of the session to lookup
59+
/// * `session`: The session to lookup
6060
///
6161
/// # Errors
6262
///
6363
/// Returns [`Self::Error`] if the underlying repository fails
6464
async fn find_active_for_session(
6565
&mut self,
66-
session_id: Ulid,
66+
session: &PersonalSession,
6767
) -> Result<Option<PersonalAccessToken>, Self::Error>;
6868

6969
/// Add a new access token to the database
@@ -120,7 +120,7 @@ repository_impl!(PersonalAccessTokenRepository:
120120

121121
async fn find_active_for_session(
122122
&mut self,
123-
session_id: Ulid,
123+
session: &PersonalSession,
124124
) -> Result<Option<PersonalAccessToken>, Self::Error>;
125125

126126
async fn add(

0 commit comments

Comments
 (0)