Commit 26ca361b authored by Davide Aprea's avatar Davide Aprea
Browse files

removed redirect to start page when sending key

parent 95845942
......@@ -12,9 +12,20 @@ class KeyController extends Controller
{
$redirUrl = $request->input('redirUrl', "");
return view('key')
->with('title', trans('titles.key'));
$cookie = Cookie::get('key');
$key = $request->input('key', '');
if(empty($key) && empty($cookie)){
$key = 'enter_key_here';
}elseif(empty($key) && !empty($cookie)){
$key = $cookie;
}elseif(!empty($key)){
$key = $request->input('key');
}
return view('key')
->with('title', trans('titles.key'))
->with('cookie', $key);
}
public function setKey(Request $request)
......@@ -29,12 +40,24 @@ class KeyController extends Controller
$host = $request->header("Host", "");
}
Cookie::queue('key', $key, 525600, '/', null, false, false);
return redirect($redirUrl);
$cookie = Cookie::get('key');
if(empty($key) && empty($cookie)){
$key = 'enter_key_here';
}elseif(empty($key) && !empty($cookie)){
$key = $cookie;
}elseif(!empty($key)){
$key = $request->input('key');
}
return view('key')
->with('title', trans('titles.key'))
->with('cookie', $key);
} else {
return view('key')
->with('title', trans('titles.key'))
->with('keyValid', false);
->with('keyValid', false)
->with('cookie', 'enter_key_here');
}
}
......
......@@ -24,7 +24,7 @@
<li>
@lang ('key.li1')
<div class="copyLink">
<input id="loadSettings" class="loadSettings" type="text" value="{{route('loadSettings', ["key" => empty(Cookie::get('key')) ? "enter_key_here" : Cookie::get('key')])}}">
<input id="loadSettings" class="loadSettings" type="text" value="{{route('loadSettings', ["key" => $cookie])}}">
<button class="js-only btn btn-default" onclick="var copyText = document.getElementById('loadSettings');copyText.select();copyText.setSelectionRange(0, 99999);document.execCommand('copy');">@lang('settings.copy')</button>
</div>
</li>
......@@ -32,7 +32,7 @@
<li>
@lang('key.li2')
<div class="copyLink">
<input id="searchString" class="loadSettings" type="text" value="{{route("resultpage", ["key" => empty(Cookie::get('key')) ? "enter_key_here" : Cookie::get('key')]) . "&eingabe=%s"}}">
<input id="searchString" class="loadSettings" type="text" value="{{route("resultpage", ["key" => $cookie]) . "&eingabe=%s"}}">
<button class="js-only btn btn-default" onclick="var copyText = document.getElementById('searchString');copyText.select();copyText.setSelectionRange(0, 99999);document.execCommand('copy');">@lang('settings.copy')</button>
</div>
</li>
......@@ -42,10 +42,10 @@
<div id="form-wrapper">
<form method="post">
<input type="hidden" name="redirUrl" value="{{ Request::input('redirUrl', '') }}" />
<input type="text" name="key" value="{{Cookie::get('key')}}" placeholder="@lang('key.placeholder1')" autofocus>
<input type="text" name="key" value="{{$cookie === 'enter_key_here' ? '' : $cookie}}" placeholder="@lang('key.placeholder1')" autofocus>
<button type="submit" class="btn btn-success">OK</button>
</form>
@if(Cookie::get('key') !== NULL)
@if($cookie !== 'enter_key_here')
<form method="post" action="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), action('KeyController@removeKey', ['redirUrl' => url()->full()])) }}">
<input type="hidden" name="redirUrl" value="{{ Request::input('redirUrl', '') }}" />
<button type="submit" class="btn btn-default">@lang('key.removeKey')</button>
......
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