Skip to content
Snippets Groups Projects
Commit 26ca361b authored by Davide Aprea's avatar Davide Aprea
Browse files

removed redirect to start page when sending key

parent 95845942
No related branches found
No related tags found
3 merge requests!1895Development,!1758Development,!1750Resolve "minor adjustments for key page"
...@@ -12,9 +12,20 @@ class KeyController extends Controller ...@@ -12,9 +12,20 @@ class KeyController extends Controller
{ {
$redirUrl = $request->input('redirUrl', ""); $redirUrl = $request->input('redirUrl', "");
return view('key') $cookie = Cookie::get('key');
->with('title', trans('titles.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) public function setKey(Request $request)
...@@ -29,12 +40,24 @@ class KeyController extends Controller ...@@ -29,12 +40,24 @@ class KeyController extends Controller
$host = $request->header("Host", ""); $host = $request->header("Host", "");
} }
Cookie::queue('key', $key, 525600, '/', null, false, false); $cookie = Cookie::get('key');
return redirect($redirUrl);
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 { } else {
return view('key') return view('key')
->with('title', trans('titles.key')) ->with('title', trans('titles.key'))
->with('keyValid', false); ->with('keyValid', false)
->with('cookie', 'enter_key_here');
} }
} }
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<li> <li>
@lang ('key.li1') @lang ('key.li1')
<div class="copyLink"> <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> <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> </div>
</li> </li>
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<li> <li>
@lang('key.li2') @lang('key.li2')
<div class="copyLink"> <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> <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> </div>
</li> </li>
...@@ -42,10 +42,10 @@ ...@@ -42,10 +42,10 @@
<div id="form-wrapper"> <div id="form-wrapper">
<form method="post"> <form method="post">
<input type="hidden" name="redirUrl" value="{{ Request::input('redirUrl', '') }}" /> <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> <button type="submit" class="btn btn-success">OK</button>
</form> </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()])) }}"> <form method="post" action="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), action('KeyController@removeKey', ['redirUrl' => url()->full()])) }}">
<input type="hidden" name="redirUrl" value="{{ Request::input('redirUrl', '') }}" /> <input type="hidden" name="redirUrl" value="{{ Request::input('redirUrl', '') }}" />
<button type="submit" class="btn btn-default">@lang('key.removeKey')</button> <button type="submit" class="btn btn-default">@lang('key.removeKey')</button>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment