mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-21 11:48:53 +00:00
@@ -12,7 +12,13 @@ declare(strict_types = 1);
|
|||||||
namespace FireflyIII\Http\Controllers\Admin;
|
namespace FireflyIII\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
|
||||||
|
use Config;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
|
use FireflyIII\Http\Requests\ConfigurationRequest;
|
||||||
|
use FireflyIII\Support\Facades\FireflyConfig;
|
||||||
|
use Preferences;
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,8 +48,30 @@ class ConfigurationController extends Controller
|
|||||||
$subTitle = strval(trans('firefly.instance_configuration'));
|
$subTitle = strval(trans('firefly.instance_configuration'));
|
||||||
$subTitleIcon = 'fa-wrench';
|
$subTitleIcon = 'fa-wrench';
|
||||||
|
|
||||||
return view('admin.configuration.index', compact('subTitle', 'subTitleIcon'));
|
// all available configuration and their default value in case
|
||||||
|
// they don't exist yet.
|
||||||
|
$singleUserMode = FireflyConfig::get('single_user_mode', Config::get('firefly.configuration.single_user_mode'))->data;
|
||||||
|
|
||||||
|
return view('admin.configuration.index', compact('subTitle', 'subTitleIcon', 'singleUserMode'));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ConfigurationRequest $request
|
||||||
|
*/
|
||||||
|
public function store(ConfigurationRequest $request)
|
||||||
|
{
|
||||||
|
// get config values:
|
||||||
|
$singleUserMode = intval($request->get('single_user_mode')) === 1 ? true : false;
|
||||||
|
|
||||||
|
// store config values
|
||||||
|
FireflyConfig::set('single_user_mode', $singleUserMode);
|
||||||
|
|
||||||
|
// flash message
|
||||||
|
Session::flash('success', strval(trans('firefly.configuration_updated')));
|
||||||
|
Preferences::mark();
|
||||||
|
|
||||||
|
return Redirect::route('admin.configuration.index');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,7 @@ declare(strict_types = 1);
|
|||||||
namespace FireflyIII\Http\Controllers\Auth;
|
namespace FireflyIII\Http\Controllers\Auth;
|
||||||
|
|
||||||
use Auth;
|
use Auth;
|
||||||
|
use Config;
|
||||||
use FireflyIII\Events\UserRegistration;
|
use FireflyIII\Events\UserRegistration;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
@@ -108,6 +109,15 @@ class AuthController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function register(Request $request)
|
public function register(Request $request)
|
||||||
{
|
{
|
||||||
|
// is allowed to?
|
||||||
|
$singleUserMode = FireflyConfig::get('single_user_mode', Config::get('firefly.configuration.single_user_mode'))->data;
|
||||||
|
if ($singleUserMode === true) {
|
||||||
|
$message = 'Registration is currently not available.';
|
||||||
|
|
||||||
|
return view('error', compact('message'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$validator = $this->validator($request->all());
|
$validator = $this->validator($request->all());
|
||||||
|
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
@@ -145,6 +155,19 @@ class AuthController extends Controller
|
|||||||
return redirect($this->redirectPath());
|
return redirect($this->redirectPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the application login form.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function showLoginForm()
|
||||||
|
{
|
||||||
|
// is allowed to?
|
||||||
|
$singleUserMode = FireflyConfig::get('single_user_mode', Config::get('firefly.configuration.single_user_mode'))->data;
|
||||||
|
|
||||||
|
return view('auth.login', compact('singleUserMode'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the application registration form.
|
* Show the application registration form.
|
||||||
*
|
*
|
||||||
@@ -154,6 +177,14 @@ class AuthController extends Controller
|
|||||||
{
|
{
|
||||||
$showDemoWarning = env('SHOW_DEMO_WARNING', false);
|
$showDemoWarning = env('SHOW_DEMO_WARNING', false);
|
||||||
|
|
||||||
|
// is allowed to?
|
||||||
|
$singleUserMode = FireflyConfig::get('single_user_mode', Config::get('firefly.configuration.single_user_mode'))->data;
|
||||||
|
if ($singleUserMode === true) {
|
||||||
|
$message = 'Registration is currently not available.';
|
||||||
|
|
||||||
|
return view('error', compact('message'));
|
||||||
|
}
|
||||||
|
|
||||||
return view('auth.register', compact('showDemoWarning'));
|
return view('auth.register', compact('showDemoWarning'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
44
app/Http/Requests/ConfigurationRequest.php
Normal file
44
app/Http/Requests/ConfigurationRequest.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ConfigurationRequest.php
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ConfigurationRequest
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Http\Requests
|
||||||
|
*/
|
||||||
|
class ConfigurationRequest extends Request
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
// Only allow logged in users and admins
|
||||||
|
return Auth::check() && Auth::user()->hasRole('owner');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'single_user_mode' => 'between:0,1|numeric',
|
||||||
|
];
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
@@ -437,6 +437,7 @@ Route::group(
|
|||||||
|
|
||||||
// FF configuration:
|
// FF configuration:
|
||||||
Route::get('/admin/configuration', ['uses' => 'Admin\ConfigurationController@index', 'as' => 'admin.configuration.index']);
|
Route::get('/admin/configuration', ['uses' => 'Admin\ConfigurationController@index', 'as' => 'admin.configuration.index']);
|
||||||
|
Route::post('/admin/configuration', ['uses' => 'Admin\ConfigurationController@store', 'as' => 'admin.configuration.store']);
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@@ -79,6 +79,17 @@ class FireflyConfig
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $name
|
||||||
|
* @param $value
|
||||||
|
*
|
||||||
|
* @return Configuration
|
||||||
|
*/
|
||||||
|
public function put($name, $value): Configuration
|
||||||
|
{
|
||||||
|
return $this->set($name, $value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param string $value
|
* @param string $value
|
||||||
|
@@ -4,7 +4,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
'allow_register' => true,
|
|
||||||
'defaults' => [
|
'defaults' => [
|
||||||
'guard' => 'web',
|
'guard' => 'web',
|
||||||
'passwords' => 'users',
|
'passwords' => 'users',
|
||||||
|
@@ -3,6 +3,12 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
|
// default values for editable configuration:
|
||||||
|
'configuration' => [
|
||||||
|
'single_user_mode' => true,
|
||||||
|
],
|
||||||
|
|
||||||
'chart' => 'chartjs',
|
'chart' => 'chartjs',
|
||||||
'version' => '3.10.2',
|
'version' => '3.10.2',
|
||||||
'csv_import_enabled' => true,
|
'csv_import_enabled' => true,
|
||||||
|
@@ -726,6 +726,10 @@ return [
|
|||||||
'instance_configuration' => 'Configuration',
|
'instance_configuration' => 'Configuration',
|
||||||
'firefly_instance_configuration' => 'Configuration options for Firefly III',
|
'firefly_instance_configuration' => 'Configuration options for Firefly III',
|
||||||
|
|
||||||
|
'setting_single_user_mode' => 'Single user mode',
|
||||||
|
'setting_single_user_mode_explain' => 'By default, Firefly III only accepts one (1) registration: you. This is a security measure, preventing others from using your instance unless you allow them to. Future registrations are blocked. When you uncheck this box, others can use your instance as wel, assuming they can reach it (when it is connected to the internet).',
|
||||||
|
'store_configuration' => 'Store configuration',
|
||||||
|
|
||||||
// split a transaction:
|
// split a transaction:
|
||||||
'transaction_meta_data' => 'Transaction meta-data',
|
'transaction_meta_data' => 'Transaction meta-data',
|
||||||
'transaction_dates' => 'Transaction dates',
|
'transaction_dates' => 'Transaction dates',
|
||||||
@@ -797,4 +801,6 @@ return [
|
|||||||
'import_with_key' => 'Import with key \':key\'',
|
'import_with_key' => 'Import with key \':key\'',
|
||||||
'import_finished_report' => 'The import has finished. Please note any errors in the block above this line. All transactions imported during this particular session have been tagged, and you can check them out below. ',
|
'import_finished_report' => 'The import has finished. Please note any errors in the block above this line. All transactions imported during this particular session have been tagged, and you can check them out below. ',
|
||||||
'import_finished_link' => 'The transactions imported can be found in tag <a href=":link" class="label label-success" style="font-size:100%;font-weight:normal;">:tag</a>.',
|
'import_finished_link' => 'The transactions imported can be found in tag <a href=":link" class="label label-success" style="font-size:100%;font-weight:normal;">:tag</a>.',
|
||||||
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
@@ -133,6 +133,7 @@ return [
|
|||||||
|
|
||||||
// admin
|
// admin
|
||||||
'domain' => 'Domain',
|
'domain' => 'Domain',
|
||||||
|
'single_user_mode' => 'Single user mode',
|
||||||
|
|
||||||
// import
|
// import
|
||||||
'import_file' => 'Import file',
|
'import_file' => 'Import file',
|
||||||
@@ -145,5 +146,4 @@ return [
|
|||||||
'csv_import_account' => 'Default import account',
|
'csv_import_account' => 'Default import account',
|
||||||
'csv_config' => 'CSV import configuration',
|
'csv_config' => 'CSV import configuration',
|
||||||
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
@@ -4,8 +4,29 @@
|
|||||||
{{ Breadcrumbs.renderIfExists }}
|
{{ Breadcrumbs.renderIfExists }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<form action="{{ route('admin.configuration.store') }}" method="post" id="store" class="form-horizontal">
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
|
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
||||||
|
|
||||||
|
<!-- single user mode -->
|
||||||
|
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
||||||
|
<div class="box box-default">
|
||||||
|
<div class="box-header with-border">
|
||||||
|
<h3 class="box-title">{{ 'setting_single_user_mode'|_ }}</h3>
|
||||||
|
</div>
|
||||||
|
<div class="box-body">
|
||||||
|
<p class="text-info">
|
||||||
|
{{ 'setting_single_user_mode_explain'|_ }}
|
||||||
|
</p>
|
||||||
|
{{ ExpandedForm.checkbox('single_user_mode','1', singleUserMode) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- configuration setting block -->
|
<!-- configuration setting block -->
|
||||||
|
<!--
|
||||||
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
||||||
<div class="box box-default">
|
<div class="box box-default">
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
@@ -16,5 +37,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
-->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
||||||
|
<button type="submit" class="btn btn-success">
|
||||||
|
{{ ('store_configuration')|_ }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -53,7 +53,7 @@
|
|||||||
<!-- /.col -->
|
<!-- /.col -->
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{% if Config.get('auth.allow_register') %}
|
{% if not singleUserMode %}
|
||||||
<a href="{{ URL.to('/register') }}" class="text-center">Register a new account</a><br>
|
<a href="{{ URL.to('/register') }}" class="text-center">Register a new account</a><br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="{{ URL.to('/password/reset') }}">I forgot my password</a>
|
<a href="{{ URL.to('/password/reset') }}">I forgot my password</a>
|
||||||
|
Reference in New Issue
Block a user