mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-25 08:21:08 -06:00
parent
598e97d028
commit
f3a8a25872
@ -12,7 +12,13 @@ declare(strict_types = 1);
|
||||
namespace FireflyIII\Http\Controllers\Admin;
|
||||
|
||||
|
||||
use Config;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Http\Requests\ConfigurationRequest;
|
||||
use FireflyIII\Support\Facades\FireflyConfig;
|
||||
use Preferences;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use View;
|
||||
|
||||
/**
|
||||
@ -42,8 +48,30 @@ class ConfigurationController extends Controller
|
||||
$subTitle = strval(trans('firefly.instance_configuration'));
|
||||
$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;
|
||||
|
||||
use Auth;
|
||||
use Config;
|
||||
use FireflyIII\Events\UserRegistration;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
@ -108,6 +109,15 @@ class AuthController extends Controller
|
||||
*/
|
||||
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());
|
||||
|
||||
if ($validator->fails()) {
|
||||
@ -145,6 +155,19 @@ class AuthController extends Controller
|
||||
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.
|
||||
*
|
||||
@ -154,6 +177,14 @@ class AuthController extends Controller
|
||||
{
|
||||
$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'));
|
||||
}
|
||||
|
||||
|
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:
|
||||
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 string $value
|
||||
|
@ -4,7 +4,6 @@ declare(strict_types = 1);
|
||||
|
||||
return [
|
||||
|
||||
'allow_register' => true,
|
||||
'defaults' => [
|
||||
'guard' => 'web',
|
||||
'passwords' => 'users',
|
||||
|
@ -3,6 +3,12 @@ declare(strict_types = 1);
|
||||
|
||||
|
||||
return [
|
||||
|
||||
// default values for editable configuration:
|
||||
'configuration' => [
|
||||
'single_user_mode' => true,
|
||||
],
|
||||
|
||||
'chart' => 'chartjs',
|
||||
'version' => '3.10.2',
|
||||
'csv_import_enabled' => true,
|
||||
|
@ -726,75 +726,81 @@ return [
|
||||
'instance_configuration' => 'Configuration',
|
||||
'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:
|
||||
'transaction_meta_data' => 'Transaction meta-data',
|
||||
'transaction_dates' => 'Transaction dates',
|
||||
'splits' => 'Splits',
|
||||
'split_title_withdrawal' => 'Split your new withdrawal',
|
||||
'split_intro_one_withdrawal' => 'Firefly supports the "splitting" of a withdrawal.',
|
||||
'split_intro_two_withdrawal' => 'It means that the amount of money you\'ve spent is divided between several destination expense accounts, budgets or categories.',
|
||||
'split_intro_three_withdrawal' => 'For example: you could split your :total groceries so you pay :split_one from your "daily groceries" budget and :split_two from your "cigarettes" budget.',
|
||||
'split_table_intro_withdrawal' => 'Split your withdrawal in as many things as you want. By default the transaction will not split, there is just one entry. Add as many splits as you want to, below. Remember that you should not deviate from your total amount. If you do, Firefly will warn you but not correct you.',
|
||||
'store_splitted_withdrawal' => 'Store splitted withdrawal',
|
||||
'update_splitted_withdrawal' => 'Update splitted withdrawal',
|
||||
'split_title_deposit' => 'Split your new deposit',
|
||||
'split_intro_one_deposit' => 'Firefly supports the "splitting" of a deposit.',
|
||||
'split_intro_two_deposit' => 'It means that the amount of money you\'ve earned is divided between several source revenue accounts or categories.',
|
||||
'split_intro_three_deposit' => 'For example: you could split your :total salary so you get :split_one as your base salary and :split_two as a reimbursment for expenses made.',
|
||||
'split_table_intro_deposit' => 'Split your deposit in as many things as you want. By default the transaction will not split, there is just one entry. Add as many splits as you want to, below. Remember that you should not deviate from your total amount. If you do, Firefly will warn you but not correct you.',
|
||||
'store_splitted_deposit' => 'Store splitted deposit',
|
||||
'split_title_transfer' => 'Split your new transfer',
|
||||
'split_intro_one_transfer' => 'Firefly supports the "splitting" of a transfer.',
|
||||
'split_intro_two_transfer' => 'It means that the amount of money you\'re moving is divided between several categories or piggy banks.',
|
||||
'split_intro_three_transfer' => 'For example: you could split your :total move so you get :split_one in one piggy bank and :split_two in another.',
|
||||
'split_table_intro_transfer' => 'Split your transfer in as many things as you want. By default the transaction will not split, there is just one entry. Add as many splits as you want to, below. Remember that you should not deviate from your total amount. If you do, Firefly will warn you but not correct you.',
|
||||
'store_splitted_transfer' => 'Store splitted transfer',
|
||||
'add_another_split' => 'Add another split',
|
||||
'split-transactions' => 'Split transactions',
|
||||
'split-new-transaction' => 'Split a new transaction',
|
||||
'do_split' => 'Do a split',
|
||||
'split_this_withdrawal' => 'Split this withdrawal',
|
||||
'split_this_deposit' => 'Split this deposit',
|
||||
'split_this_transfer' => 'Split this transfer',
|
||||
'cannot_edit_multiple_source' => 'You cannot edit splitted transaction #:id with description ":description" because it contains multiple source accounts.',
|
||||
'cannot_edit_multiple_dest' => 'You cannot edit splitted transaction #:id with description ":description" because it contains multiple destination accounts.',
|
||||
'no_edit_multiple_left' => 'You have selected no valid transactions to edit.',
|
||||
'transaction_meta_data' => 'Transaction meta-data',
|
||||
'transaction_dates' => 'Transaction dates',
|
||||
'splits' => 'Splits',
|
||||
'split_title_withdrawal' => 'Split your new withdrawal',
|
||||
'split_intro_one_withdrawal' => 'Firefly supports the "splitting" of a withdrawal.',
|
||||
'split_intro_two_withdrawal' => 'It means that the amount of money you\'ve spent is divided between several destination expense accounts, budgets or categories.',
|
||||
'split_intro_three_withdrawal' => 'For example: you could split your :total groceries so you pay :split_one from your "daily groceries" budget and :split_two from your "cigarettes" budget.',
|
||||
'split_table_intro_withdrawal' => 'Split your withdrawal in as many things as you want. By default the transaction will not split, there is just one entry. Add as many splits as you want to, below. Remember that you should not deviate from your total amount. If you do, Firefly will warn you but not correct you.',
|
||||
'store_splitted_withdrawal' => 'Store splitted withdrawal',
|
||||
'update_splitted_withdrawal' => 'Update splitted withdrawal',
|
||||
'split_title_deposit' => 'Split your new deposit',
|
||||
'split_intro_one_deposit' => 'Firefly supports the "splitting" of a deposit.',
|
||||
'split_intro_two_deposit' => 'It means that the amount of money you\'ve earned is divided between several source revenue accounts or categories.',
|
||||
'split_intro_three_deposit' => 'For example: you could split your :total salary so you get :split_one as your base salary and :split_two as a reimbursment for expenses made.',
|
||||
'split_table_intro_deposit' => 'Split your deposit in as many things as you want. By default the transaction will not split, there is just one entry. Add as many splits as you want to, below. Remember that you should not deviate from your total amount. If you do, Firefly will warn you but not correct you.',
|
||||
'store_splitted_deposit' => 'Store splitted deposit',
|
||||
'split_title_transfer' => 'Split your new transfer',
|
||||
'split_intro_one_transfer' => 'Firefly supports the "splitting" of a transfer.',
|
||||
'split_intro_two_transfer' => 'It means that the amount of money you\'re moving is divided between several categories or piggy banks.',
|
||||
'split_intro_three_transfer' => 'For example: you could split your :total move so you get :split_one in one piggy bank and :split_two in another.',
|
||||
'split_table_intro_transfer' => 'Split your transfer in as many things as you want. By default the transaction will not split, there is just one entry. Add as many splits as you want to, below. Remember that you should not deviate from your total amount. If you do, Firefly will warn you but not correct you.',
|
||||
'store_splitted_transfer' => 'Store splitted transfer',
|
||||
'add_another_split' => 'Add another split',
|
||||
'split-transactions' => 'Split transactions',
|
||||
'split-new-transaction' => 'Split a new transaction',
|
||||
'do_split' => 'Do a split',
|
||||
'split_this_withdrawal' => 'Split this withdrawal',
|
||||
'split_this_deposit' => 'Split this deposit',
|
||||
'split_this_transfer' => 'Split this transfer',
|
||||
'cannot_edit_multiple_source' => 'You cannot edit splitted transaction #:id with description ":description" because it contains multiple source accounts.',
|
||||
'cannot_edit_multiple_dest' => 'You cannot edit splitted transaction #:id with description ":description" because it contains multiple destination accounts.',
|
||||
'no_edit_multiple_left' => 'You have selected no valid transactions to edit.',
|
||||
|
||||
// import
|
||||
'configuration_file_help' => 'If you have previously imported data into Firefly III, you may have a configuration file, which will pre-set configuration values for you.',
|
||||
'import_data_index' => 'Index',
|
||||
'import_file_type_csv' => 'CSV (comma separated values)',
|
||||
'import_file_type_help' => 'Select the type of file you will upload',
|
||||
'import_start' => 'Start the import',
|
||||
'configure_import' => 'Further configure your import',
|
||||
'import_finish_configuration' => 'Finish configuration',
|
||||
'settings_for_import' => 'Settings',
|
||||
'import_status' => 'Import status',
|
||||
'import_status_text' => 'The import is currently running, or will start momentarily.',
|
||||
'import_complete' => 'Import configuration complete!',
|
||||
'import_complete_text' => 'The import is ready to start. All the configuration you needed to do has been done. Please download the configuration file. It will help you with the import should it not go as planned. To actually run the import, you can either execute the following command in your console, or run the web-based import. Depending on your configuration, the console import will give you more feedback.',
|
||||
'import_download_config' => 'Download configuration',
|
||||
'import_start_import' => 'Start import',
|
||||
'import_intro_beta' => 'The import function of Firefly III is in beta. Many users of Firefly III have tried many different files. Although each individual compontent of this import routine works (really), the combination might break. If your file cannot be imported by Firefly, please read <a href="https://github.com/JC5/firefly-iii/wiki/Submit-issues-with-sensitive-data-in-them">this wiki page</a> so I can fix the problem you have run into.',
|
||||
'import_data' => 'Import data',
|
||||
'import_data_full' => 'Import data into Firefly III',
|
||||
'import' => 'Import',
|
||||
'import_intro_text' => 'Welcome to the Firefly III data import routine. At the moment, this routine can help you import files into Firefly. To do so, you must download or export transactions from other systems or software, and upload them here. The next steps will let you help Firefly III determin what the content is of your file, and how to handle it. Please select a file, and read all instructions carefully.',
|
||||
'import_file_help' => 'Select your file',
|
||||
'import_status_settings_complete' => 'The import is ready to start.',
|
||||
'import_status_import_complete' => 'The import has completed.',
|
||||
'import_status_import_running' => 'The import is currently running. Please be patient.',
|
||||
'import_status_header' => 'Import status and progress',
|
||||
'import_status_errors' => 'Import errors',
|
||||
'import_status_report' => 'Import report',
|
||||
'import_finished' => 'Import has finished',
|
||||
'import_error_single' => 'An error has occured during the import.',
|
||||
'import_error_multi' => 'Some errors occured during the import.',
|
||||
'import_error_fatal' => 'There was an error during the import routine. Please check the log files. The error seems to be:',
|
||||
'import_error_timeout' => 'The import seems to have timed out. If this error persists, please import your data using the console command.',
|
||||
'import_double' => 'Row #:row: This row has been imported before, and is stored in <a href=":link">:description</a>.',
|
||||
'import_finished_all' => 'The import has finished. Please check out the results below.',
|
||||
'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_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>.',
|
||||
'configuration_file_help' => 'If you have previously imported data into Firefly III, you may have a configuration file, which will pre-set configuration values for you.',
|
||||
'import_data_index' => 'Index',
|
||||
'import_file_type_csv' => 'CSV (comma separated values)',
|
||||
'import_file_type_help' => 'Select the type of file you will upload',
|
||||
'import_start' => 'Start the import',
|
||||
'configure_import' => 'Further configure your import',
|
||||
'import_finish_configuration' => 'Finish configuration',
|
||||
'settings_for_import' => 'Settings',
|
||||
'import_status' => 'Import status',
|
||||
'import_status_text' => 'The import is currently running, or will start momentarily.',
|
||||
'import_complete' => 'Import configuration complete!',
|
||||
'import_complete_text' => 'The import is ready to start. All the configuration you needed to do has been done. Please download the configuration file. It will help you with the import should it not go as planned. To actually run the import, you can either execute the following command in your console, or run the web-based import. Depending on your configuration, the console import will give you more feedback.',
|
||||
'import_download_config' => 'Download configuration',
|
||||
'import_start_import' => 'Start import',
|
||||
'import_intro_beta' => 'The import function of Firefly III is in beta. Many users of Firefly III have tried many different files. Although each individual compontent of this import routine works (really), the combination might break. If your file cannot be imported by Firefly, please read <a href="https://github.com/JC5/firefly-iii/wiki/Submit-issues-with-sensitive-data-in-them">this wiki page</a> so I can fix the problem you have run into.',
|
||||
'import_data' => 'Import data',
|
||||
'import_data_full' => 'Import data into Firefly III',
|
||||
'import' => 'Import',
|
||||
'import_intro_text' => 'Welcome to the Firefly III data import routine. At the moment, this routine can help you import files into Firefly. To do so, you must download or export transactions from other systems or software, and upload them here. The next steps will let you help Firefly III determin what the content is of your file, and how to handle it. Please select a file, and read all instructions carefully.',
|
||||
'import_file_help' => 'Select your file',
|
||||
'import_status_settings_complete' => 'The import is ready to start.',
|
||||
'import_status_import_complete' => 'The import has completed.',
|
||||
'import_status_import_running' => 'The import is currently running. Please be patient.',
|
||||
'import_status_header' => 'Import status and progress',
|
||||
'import_status_errors' => 'Import errors',
|
||||
'import_status_report' => 'Import report',
|
||||
'import_finished' => 'Import has finished',
|
||||
'import_error_single' => 'An error has occured during the import.',
|
||||
'import_error_multi' => 'Some errors occured during the import.',
|
||||
'import_error_fatal' => 'There was an error during the import routine. Please check the log files. The error seems to be:',
|
||||
'import_error_timeout' => 'The import seems to have timed out. If this error persists, please import your data using the console command.',
|
||||
'import_double' => 'Row #:row: This row has been imported before, and is stored in <a href=":link">:description</a>.',
|
||||
'import_finished_all' => 'The import has finished. Please check out the results below.',
|
||||
'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_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
|
||||
'domain' => 'Domain',
|
||||
'single_user_mode' => 'Single user mode',
|
||||
|
||||
// import
|
||||
'import_file' => 'Import file',
|
||||
@ -145,5 +146,4 @@ return [
|
||||
'csv_import_account' => 'Default import account',
|
||||
'csv_config' => 'CSV import configuration',
|
||||
|
||||
|
||||
];
|
||||
|
@ -4,17 +4,50 @@
|
||||
{{ Breadcrumbs.renderIfExists }}
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<!-- configuration setting block -->
|
||||
<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'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
Bla bla bla
|
||||
<form action="{{ route('admin.configuration.store') }}" method="post" id="store" class="form-horizontal">
|
||||
|
||||
<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 -->
|
||||
<!--
|
||||
<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'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
Bla bla bla
|
||||
</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 %}
|
||||
|
@ -53,7 +53,7 @@
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
</form>
|
||||
{% if Config.get('auth.allow_register') %}
|
||||
{% if not singleUserMode %}
|
||||
<a href="{{ URL.to('/register') }}" class="text-center">Register a new account</a><br>
|
||||
{% endif %}
|
||||
<a href="{{ URL.to('/password/reset') }}">I forgot my password</a>
|
||||
|
Loading…
Reference in New Issue
Block a user