mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-09 09:52:10 +00:00
replace expect
with ErrorUnauthorized
(#3915)
Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
This commit is contained in:
parent
b2aee565f3
commit
c93bde9799
|
@ -92,9 +92,9 @@ async fn upload(
|
||||||
context: web::Data<LemmyContext>,
|
context: web::Data<LemmyContext>,
|
||||||
) -> Result<HttpResponse, Error> {
|
) -> Result<HttpResponse, Error> {
|
||||||
// TODO: check rate limit here
|
// TODO: check rate limit here
|
||||||
let jwt = req
|
let jwt = req.cookie("jwt").ok_or(error::ErrorUnauthorized(
|
||||||
.cookie("jwt")
|
"No auth header for picture upload",
|
||||||
.expect("No auth header for picture upload");
|
))?;
|
||||||
|
|
||||||
if Claims::decode(jwt.value(), &context.secret().jwt_secret).is_err() {
|
if Claims::decode(jwt.value(), &context.secret().jwt_secret).is_err() {
|
||||||
return Ok(HttpResponse::Unauthorized().finish());
|
return Ok(HttpResponse::Unauthorized().finish());
|
||||||
|
@ -133,9 +133,9 @@ async fn full_res(
|
||||||
.await
|
.await
|
||||||
.map_err(error::ErrorBadRequest)?;
|
.map_err(error::ErrorBadRequest)?;
|
||||||
if local_site.private_instance {
|
if local_site.private_instance {
|
||||||
let jwt = req
|
let jwt = req.cookie("jwt").ok_or(error::ErrorUnauthorized(
|
||||||
.cookie("jwt")
|
"No auth header for picture access",
|
||||||
.expect("No auth header for picture access");
|
))?;
|
||||||
if local_user_view_from_jwt(jwt.value(), &context)
|
if local_user_view_from_jwt(jwt.value(), &context)
|
||||||
.await
|
.await
|
||||||
.is_err()
|
.is_err()
|
||||||
|
|
Loading…
Reference in a new issue