Added security configuration items for registration options

This commit is contained in:
Andy Heathershaw 2016-09-05 21:43:58 +01:00
parent acd5c108a1
commit 6875b0dd22
5 changed files with 56 additions and 5 deletions

View File

@ -52,8 +52,10 @@ class ConfigHelper
public function defaults()
{
return array(
'allow_self_registration' => true,
'app_name' => trans('global.app_name'),
'date_format' => $this->allowedDateFormats()[0]
'date_format' => $this->allowedDateFormats()[0],
'require_email_verification' => true
);
}

View File

@ -30,6 +30,10 @@ class DefaultController extends Controller
public function saveSettings(SaveSettingsRequest $request)
{
$checkboxKeys = [
'allow_self_registration',
'require_email_verification'
];
$updateKeys = [
'app_name',
'date_format',
@ -43,6 +47,13 @@ class DefaultController extends Controller
$config->save();
}
foreach ($checkboxKeys as $key)
{
$config = UserConfig::getOrCreateModel($key);
$config->value = ($request->request->get($key) == 'on' ? 1 : 0);
$config->save();
}
$request->session()->flash('success', trans('admin.settings_saved_message'));
return redirect(route('admin.settings'));
}

View File

@ -3,6 +3,7 @@
namespace App\Http\Controllers\Auth;
use App\Facade\Theme;
use App\Facade\UserConfig;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
@ -70,13 +71,28 @@ class RegisterController extends Controller
]);
}
public function register(Request $request)
{
if (UserConfig::get('allow_self_registration') == 1)
{
return parent::register($request);
}
return redirect(route('home'));
}
/**
* Show the application registration form.
*
* @return \Illuminate\Http\Response
*/
public function showRegistrationForm()
{
if (UserConfig::get('allow_self_registration') == 1)
{
return Theme::render('auth.register');
}
return redirect(route('home'));
}
}

View File

@ -13,12 +13,13 @@
<div>
{{-- Nav tabs --}}
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#upload-tab" aria-controls="upload-tab" role="tab" data-toggle="tab"><i class="fa fa-fw fa-info-circle"></i> General</a></li>
<li role="presentation" class="active"><a href="#general-tab" aria-controls="general-tab" role="tab" data-toggle="tab"><i class="fa fa-fw fa-info-circle"></i> General</a></li>
<li role="presentation"><a href="#security-tab" aria-controls="security-tab" role="tab" data-toggle="tab"><i class="fa fa-fw fa-lock"></i> Security</a></li>
</ul>
{{-- Tab panes --}}
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="upload-tab">
<div role="tabpanel" class="tab-pane active" id="general-tab">
<div class="form-group">
{!! Form::label('app_name', 'Gallery name:', ['class' => 'control-label']) !!}
{!! Form::text('app_name', old('app_name'), ['class' => 'form-control']) !!}
@ -42,6 +43,24 @@
</div>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="security-tab">
<div class="checkbox">
<label>
<input type="checkbox" name="allow_self_registration" @if (UserConfig::get('allow_self_registration') == 1)checked="checked"@endif>
<strong>Allow self-registration</strong><br/>
With this option enabled, users can sign up for their own &quot;visitor&quot; accounts to comment on photos.
</label>
</div>
<div class="checkbox" style="margin-top: 20px;">
<label>
<input type="checkbox" name="require_email_verification" @if (UserConfig::get('require_email_verification') == 1)checked="checked"@endif>
<strong>Require e-mail verification for self-registered accounts</strong><br/>
<span class="text-danger">It is strongly recommended to enable this option.</span>
</label>
</div>
</div>
</div>
</div>

View File

@ -39,7 +39,10 @@
{{-- Authentication Links --}}
@if (Auth::guest())
<li><a href="{{ url('/login') }}">Login</a></li>
@if (UserConfig::get('allow_self_registration') == 1)
<li><a href="{{ url('/register') }}">Register</a></li>
@endif
@else
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" style="padding-top: 4px; padding-bottom: 4px;">