mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-23 11:21:32 +00:00
parent
cc8a6bea65
commit
45efa94ba4
1 changed files with 9 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
use actix::clock::Duration;
|
use actix::clock::Duration;
|
||||||
use actix_web::{body::BodyStream, http::StatusCode, *};
|
use actix_web::{body::BodyStream, http::StatusCode, *};
|
||||||
use awc::Client;
|
use awc::Client;
|
||||||
|
use lemmy_api::claims::Claims;
|
||||||
use lemmy_rate_limit::RateLimit;
|
use lemmy_rate_limit::RateLimit;
|
||||||
use lemmy_utils::settings::Settings;
|
use lemmy_utils::settings::Settings;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -46,7 +47,14 @@ async fn upload(
|
||||||
body: web::Payload,
|
body: web::Payload,
|
||||||
client: web::Data<Client>,
|
client: web::Data<Client>,
|
||||||
) -> Result<HttpResponse, Error> {
|
) -> Result<HttpResponse, Error> {
|
||||||
// TODO: check auth and rate limit here
|
// TODO: check rate limit here
|
||||||
|
let jwt = req
|
||||||
|
.cookie("jwt")
|
||||||
|
.expect("No auth header for picture upload");
|
||||||
|
|
||||||
|
if Claims::decode(jwt.value()).is_err() {
|
||||||
|
return Ok(HttpResponse::Unauthorized().finish());
|
||||||
|
};
|
||||||
|
|
||||||
let mut res = client
|
let mut res = client
|
||||||
.request_from(format!("{}/image", Settings::get().pictrs_url), req.head())
|
.request_from(format!("{}/image", Settings::get().pictrs_url), req.head())
|
||||||
|
|
Loading…
Reference in a new issue