Commit 8f68ad1a authored by Davide Aprea's avatar Davide Aprea
Browse files

added key validation middleware

parent 1b086e68
......@@ -63,5 +63,6 @@ class Kernel extends HttpKernel
'humanverification' => \App\Http\Middleware\HumanVerification::class,
'useragentmaster' => \App\Http\Middleware\UserAgentMaster::class,
'browserverification' => \App\Http\Middleware\BrowserVerification::class,
'keyvalidation' => \App\Http\Middleware\KeyValidation::class,
];
}
<?php
namespace App\Http\Middleware;
use Closure;
use Cookie;
use App\Models\Key;
class KeyValidation
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if(isset($request->key)){
$pKey = new Key($request->key);
}
if(Cookie::get('key')){
$cKey = new Key($request->key);
}
if($pKey->getStatus() || $cKey->getStatus())
return $next($request);
}
}
......@@ -15,7 +15,7 @@ class Key{
# always returns true or false
public function getStatus() {
if($this->status === null) {
updateStatus();
$this->updateStatus();
}
if($this->status === null || $this->status === false) {
return false;
......@@ -60,7 +60,7 @@ class Key{
if ($result->{'api-access'} == true) {
return true;
} else {
$this->status = false;
$this->status = false;
return false;
}
} catch (\ErrorException $e) {
......
......@@ -197,7 +197,7 @@ Route::group(
return redirect(LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), '/'));
});
Route::match(['get', 'post'], 'meta/meta.ger3', 'MetaGerSearch@search')->middleware('browserverification', 'humanverification', 'useragentmaster')->name("resultpage");
Route::match(['get', 'post'], 'meta/meta.ger3', 'MetaGerSearch@search')->middleware('keyvalidation', 'browserverification', 'humanverification', 'useragentmaster')->name("resultpage");
Route::get('meta/loadMore', 'MetaGerSearch@loadMore');
Route::post('img/cat.jpg', 'HumanVerification@remove');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment