Commit feb45c55 authored by Dominik Hebeler's avatar Dominik Hebeler

Merge branch '1106-remove-key-cookie-from-inavlid-keys' into 'development'

Resolve "Remove Key Cookie from inavlid Keys"

Closes #1106

See merge request !1824
parents e17bc345 ecd4909f
......@@ -62,9 +62,16 @@ class KeyController extends Controller
public function removeKey(Request $request)
{
$instantRedir = $request->input("ir", "");
$redirUrl = $request->input('redirUrl', "");
Cookie::queue(Cookie::forget('key'));
Cookie::queue("key", "", 0, '/', null, false, false);
$url = LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), action('KeyController@index', ['redirUrl' => $redirUrl]));
return redirect($url);
$host = $request->getHttpHost();
if(!empty($instantRedir) && in_array($host, ["metager.de", "metager.es", "metager.org", "metager3.de", "localhost:8080"])){
return redirect($instantRedir);
}else{
return redirect($url);
}
}
}
......@@ -64,5 +64,6 @@ class Kernel extends HttpKernel
'useragentmaster' => \App\Http\Middleware\UserAgentMaster::class,
'browserverification' => \App\Http\Middleware\BrowserVerification::class,
'keyvalidation' => \App\Http\Middleware\KeyValidation::class,
'removekey' => \App\Http\Middleware\RemoveKey::class,
];
}
<?php
namespace App\Http\Middleware;
use Closure;
use Cookie;
class RemoveKey
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// Check if a wrong Key Cookie is set and if so remove it
if(Cookie::has("key") && !app('App\Models\Key')->getStatus()){
return redirect(route("removeCookie", ["ir" => url()->full()]));
}
return $next($request);
}
}
......@@ -6,9 +6,9 @@ Route::group(
'middleware' => [ 'localeSessionRedirect', 'localizationRedirect' ]*/
],
function () {
Route::get('meta/key', "KeyController@index");
Route::get('meta/key', "KeyController@index")->middleware('removekey');
Route::post('meta/key', 'KeyController@setKey');
Route::post('meta/key/remove', 'KeyController@removeKey');
Route::any('meta/key/remove', 'KeyController@removeKey')->name("removeCookie");
Route::group([
'prefix' => 'meta/settings',
......
......@@ -33,7 +33,7 @@ Route::group(
function () {
/** ADD ALL LOCALIZED ROUTES INSIDE THIS GROUP **/
Route::get('/', 'StartpageController@loadStartPage')->name("startpage");
Route::get('/', 'StartpageController@loadStartPage')->name("startpage")->middleware("removekey");
Route::get('asso', function () {
return view('assoziator.asso')
......@@ -221,7 +221,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('removekey', 'browserverification', 'humanverification', 'useragentmaster')->name("resultpage");
Route::get('meta/loadMore', 'MetaGerSearch@loadMore');
Route::post('img/cat.png', 'HumanVerification@remove');
......
Markdown is supported
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