mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-30 00:01:25 +00:00
Fix local site images. (#2519)
* Fix local site images. * It should be set up.
This commit is contained in:
parent
7aa6d6b3e1
commit
ed9e91345a
1 changed files with 14 additions and 14 deletions
|
@ -12,7 +12,7 @@ use actix_web::{
|
||||||
};
|
};
|
||||||
use futures::stream::{Stream, StreamExt};
|
use futures::stream::{Stream, StreamExt};
|
||||||
use lemmy_api_common::utils::{blocking, get_local_user_view_from_jwt};
|
use lemmy_api_common::utils::{blocking, get_local_user_view_from_jwt};
|
||||||
use lemmy_db_schema::source::site::Site;
|
use lemmy_db_schema::source::local_site::LocalSite;
|
||||||
use lemmy_utils::{claims::Claims, rate_limit::RateLimit, REQWEST_TIMEOUT};
|
use lemmy_utils::{claims::Claims, rate_limit::RateLimit, REQWEST_TIMEOUT};
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
use reqwest::Body;
|
use reqwest::Body;
|
||||||
|
@ -126,20 +126,20 @@ async fn full_res(
|
||||||
context: web::Data<LemmyContext>,
|
context: web::Data<LemmyContext>,
|
||||||
) -> Result<HttpResponse, Error> {
|
) -> Result<HttpResponse, Error> {
|
||||||
// block access to images if instance is private and unauthorized, public
|
// block access to images if instance is private and unauthorized, public
|
||||||
let site = blocking(context.pool(), Site::read_local_site).await?;
|
let local_site = blocking(context.pool(), LocalSite::read)
|
||||||
|
.await?
|
||||||
|
.map_err(error::ErrorBadRequest)?;
|
||||||
// The site might not be set up yet
|
// The site might not be set up yet
|
||||||
if let Ok(site) = site {
|
if local_site.private_instance {
|
||||||
if site.private_instance {
|
let jwt = req
|
||||||
let jwt = req
|
.cookie("jwt")
|
||||||
.cookie("jwt")
|
.expect("No auth header for picture access");
|
||||||
.expect("No auth header for picture access");
|
if get_local_user_view_from_jwt(jwt.value(), context.pool(), context.secret())
|
||||||
if get_local_user_view_from_jwt(jwt.value(), context.pool(), context.secret())
|
.await
|
||||||
.await
|
.is_err()
|
||||||
.is_err()
|
{
|
||||||
{
|
return Ok(HttpResponse::Unauthorized().finish());
|
||||||
return Ok(HttpResponse::Unauthorized().finish());
|
};
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
let name = &filename.into_inner();
|
let name = &filename.into_inner();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue