Commit e639e706 authored by Davide Aprea's avatar Davide Aprea
Browse files

added full settings link to key page

parent ee700786
......@@ -5,15 +5,15 @@ namespace App\Http\Controllers;
use Cookie;
use Illuminate\Http\Request;
use LaravelLocalization;
use \App\Models\Key;
class KeyController extends Controller
{
public function index(Request $request)
{
$redirUrl = $request->input('redirUrl', "");
$cookie = Cookie::get('key');
$key = $request->input('key', '');
$key = $request->input('keyToSet', '');
if(empty($key) && empty($cookie)){
$key = 'enter_key_here';
......@@ -23,42 +23,40 @@ class KeyController extends Controller
$key = $request->input('key');
}
$cookieLink = LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('loadSettings', Cookie::get()));
return view('key')
->with('title', trans('titles.key'))
->with('cookie', $key);
->with('cookie', $key)
->with('cookieLink', $cookieLink);
}
public function setKey(Request $request)
{
$redirUrl = $request->input('redirUrl', "");
$key = $request->input('key', '');
$keyToSet = $request->input('keyToSet');
$key = new Key ($request->input('keyToSet', ''));
if (app('App\Models\Key')->getStatus()) {
if ($key->getStatus()) {
# Valid Key
$host = $request->header("X_Forwarded_Host", "");
if (empty($host)) {
$host = $request->header("Host", "");
}
$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');
Cookie::queue('key', $key, 0, '/', null, false, false);
}
Cookie::queue('key', $keyToSet, 0, '/', null, false, false);
$settings = Cookie::get();
$settings['key'] = $keyToSet;
$cookieLink = LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('loadSettings', $settings));
return view('key')
->with('title', trans('titles.key'))
->with('cookie', $key);
->with('title', trans('titles.key'))
->with('cookie', $keyToSet)
->with('cookieLink', $cookieLink);
} else {
$cookieLink = LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('loadSettings', Cookie::get()));
return view('key')
->with('title', trans('titles.key'))
->with('keyValid', false)
->with('cookie', 'enter_key_here');
->with('cookie', 'enter_key_here')
->with('cookieLink', $cookieLink);
}
}
......
......@@ -24,7 +24,7 @@
<li>
@lang ('key.li1')
<div class="copyLink">
<input id="loadSettings" class="loadSettings" type="text" value="{{route('loadSettings', ["key" => $cookie])}}">
<input id="loadSettings" class="loadSettings" type="text" value="{{$cookieLink}}">
<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>
......@@ -42,7 +42,7 @@
<div id="form-wrapper">
<form method="post">
<input type="hidden" name="redirUrl" value="{{ Request::input('redirUrl', '') }}" />
<input type="text" name="key" value="{{$cookie === 'enter_key_here' ? '' : $cookie}}" placeholder="@lang('key.placeholder1')" autofocus>
<input type="text" name="keyToSet" value="{{$cookie === 'enter_key_here' ? '' : $cookie}}" placeholder="@lang('key.placeholder1')" autofocus>
<button type="submit" class="btn btn-success">OK</button>
</form>
@if($cookie !== 'enter_key_here')
......
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