Skip to content

Commit

Permalink
replace expect with ErrorUnauthorized (#3915)
Browse files Browse the repository at this point in the history
Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
  • Loading branch information
Trombach and dessalines committed Aug 29, 2023
1 parent b2aee56 commit c93bde9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crates/routes/src/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ async fn upload(
context: web::Data<LemmyContext>,
) -> Result<HttpResponse, Error> {
// TODO: check rate limit here
let jwt = req
.cookie("jwt")
.expect("No auth header for picture upload");
let jwt = req.cookie("jwt").ok_or(error::ErrorUnauthorized(
"No auth header for picture upload",
))?;

if Claims::decode(jwt.value(), &context.secret().jwt_secret).is_err() {
return Ok(HttpResponse::Unauthorized().finish());
Expand Down Expand Up @@ -133,9 +133,9 @@ async fn full_res(
.await
.map_err(error::ErrorBadRequest)?;
if local_site.private_instance {
let jwt = req
.cookie("jwt")
.expect("No auth header for picture access");
let jwt = req.cookie("jwt").ok_or(error::ErrorUnauthorized(
"No auth header for picture access",
))?;
if local_user_view_from_jwt(jwt.value(), &context)
.await
.is_err()
Expand Down

0 comments on commit c93bde9

Please sign in to comment.