mirror of
https://framagit.org/fiat-tux/hat-softwares/lutim.git
synced 2026-08-07 01:12:49 +02:00
Tester aussi le referer sans quoi ça ne peut pas fonctionner (à squasher avec le commit précédent).
This commit is contained in:
@@ -288,19 +288,21 @@ sub add {
|
||||
my $wm = $c->param('watermark');
|
||||
|
||||
if ($c->config('disable_api')) {
|
||||
my $msg = $c->l('Sorry, the API is disabled');
|
||||
$c->app->log->info('Blocked API call for '.$ip);
|
||||
return $c->respond_to(
|
||||
json => { json => { success => Mojo::JSON->false, msg => $msg } },
|
||||
any => sub {
|
||||
shift->render(
|
||||
template => 'index',
|
||||
msg => $msg,
|
||||
);
|
||||
}
|
||||
);
|
||||
$unauthorized_api = (!defined($c->req->headers->referrer) || Mojo::URL->new($c->req->headers->referrer)->host ne Mojo::URL->new('https://'.$c->req->headers->host)->host);
|
||||
if ($unauthorized_api) {
|
||||
my $msg = $c->l('Sorry, the API is disabled');
|
||||
$c->app->log->info('Blocked API call for '.$ip);
|
||||
return $c->respond_to(
|
||||
json => { json => { success => Mojo::JSON->false, msg => $msg } },
|
||||
any => sub {
|
||||
shift->render(
|
||||
template => 'index',
|
||||
msg => $msg,
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if(!defined($c->stash('stop_upload'))) {
|
||||
if (defined($file_url) && $file_url) {
|
||||
if (is_http_uri($file_url) || is_https_uri($file_url)) {
|
||||
|
||||
Reference in New Issue
Block a user