Skip to content

Commit 9e0d9c0

Browse files
committed
sentry - middleware - auth - fix except()s:
- for-advertiser - for-publisher
1 parent 4d354e1 commit 9e0d9c0

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

sentry/src/middleware/auth.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,14 @@ pub async fn authenticate_as_advertiser<B>(
192192
.ok_or(ResponseError::Unauthorized)?
193193
.uid;
194194

195-
request
195+
let previous = request
196196
.extensions_mut()
197-
.insert(AuthenticateAs::Advertiser(auth_uid))
198-
.expect("Should not contain previous value of AuthenticateAs");
197+
.insert(AuthenticateAs::Advertiser(auth_uid));
198+
199+
assert!(
200+
previous.is_none(),
201+
"Should not contain previous value of AuthenticateAs"
202+
);
199203

200204
Ok(next.run(request).await)
201205
}
@@ -210,10 +214,14 @@ pub async fn authenticate_as_publisher<B>(
210214
.ok_or(ResponseError::Unauthorized)?
211215
.uid;
212216

213-
request
217+
let previous = request
214218
.extensions_mut()
215-
.insert(AuthenticateAs::Publisher(auth_uid))
216-
.expect("Should not contain previous value of AuthenticateAs");
219+
.insert(AuthenticateAs::Publisher(auth_uid));
220+
221+
assert!(
222+
previous.is_none(),
223+
"Should not contain previous value of AuthenticateAs"
224+
);
217225

218226
Ok(next.run(request).await)
219227
}

0 commit comments

Comments
 (0)