Skip to content

Commit e44cb5e

Browse files
authored
fix(labrinth): charge user check (#8337)
fix(labrinth): DBCharge user ownership check Reported-by: Haam
1 parent 761b04a commit e44cb5e

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

‎apps/labrinth/src/routes/internal/billing.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,6 +1789,7 @@ pub async fn initiate_payment(
17891789
},
17901790
attached_charge: AttachedCharge::from_charge_request_type(
17911791
&**pool,
1792+
&user,
17921793
payment_request.charge,
17931794
)
17941795
.await

‎apps/labrinth/src/routes/internal/billing/payments.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,15 @@ impl AttachedCharge {
139139

140140
pub async fn from_charge_request_type(
141141
exec: impl crate::database::Executor<'_, Database = sqlx::Postgres>,
142+
user: &User,
142143
charge_request_type: ChargeRequestType,
143144
) -> Result<Self, ApiError> {
144145
Ok(match charge_request_type {
145146
ChargeRequestType::Existing { id } => AttachedCharge::UseExisting {
146147
charge: DBCharge::get(id.into(), exec)
147148
.await
148149
.wrap_internal_err("fetching charge from database")?
150+
.filter(|charge| charge.user_id == user.id.into())
149151
.wrap_request_err_with(|| {
150152
"could not find charge".to_string()
151153
})?,

0 commit comments

Comments
 (0)