Move options to config/2fauth

This commit is contained in:
Bubka 2021-10-08 23:27:15 +02:00
parent a58a4a3def
commit 2cb4578109
6 changed files with 36 additions and 29 deletions

View File

@ -140,7 +140,7 @@ public function destroy($settingName)
abort(404); abort(404);
} }
$optionsConfig = config('app.options'); $optionsConfig = config('2fauth.options');
if(array_key_exists($settingName, $optionsConfig)) { if(array_key_exists($settingName, $optionsConfig)) {
return response()->json( return response()->json(
['message' => 'bad request', ['message' => 'bad request',

View File

@ -12,7 +12,7 @@ class AppstractOptionsService implements SettingServiceInterface
*/ */
public function get(string $setting) public function get(string $setting)
{ {
$value = option($setting, config('app.options' . $setting)); $value = option($setting, config('2fauth.options' . $setting));
$value = $this->restoreType($value); $value = $this->restoreType($value);
return $value; return $value;
@ -29,7 +29,7 @@ public function all() : Collection
$userOptions->transform(function ($item, $key) { $userOptions->transform(function ($item, $key) {
return $this->restoreType($item); return $this->restoreType($item);
}); });
$userOptions = collect(config('app.options'))->merge($userOptions); $userOptions = collect(config('2fauth.options'))->merge($userOptions);
return $userOptions; return $userOptions;
} }

View File

@ -2,8 +2,37 @@
return [ return [
/*
|--------------------------------------------------------------------------
| 2FAuth config
|--------------------------------------------------------------------------
|
*/
'config' => [ 'config' => [
'isDemoApp' => env('IS_DEMO_APP', false), 'isDemoApp' => env('IS_DEMO_APP', false),
], ],
/*
|--------------------------------------------------------------------------
| Application fallback for user options
|--------------------------------------------------------------------------
|
*/
'options' => [
'showTokenAsDot' => false,
'closeOtpOnCopy' => false,
'useBasicQrcodeReader' => false,
'displayMode' => 'list',
'showAccountsIcons' => true,
'kickUserAfter' => '15',
'activeGroup' => 0,
'rememberActiveGroup' => true,
'defaultGroup' => 0,
'useEncryption' => false,
'defaultCaptureMode' => 'livescan',
'useDirectCapture' => false,
],
]; ];

View File

@ -24,28 +24,6 @@
'version' => '2.1.0', 'version' => '2.1.0',
/*
|--------------------------------------------------------------------------
| Application fallback for user options
|--------------------------------------------------------------------------
|
*/
'options' => [
'showTokenAsDot' => false,
'closeTokenOnCopy' => false,
'useBasicQrcodeReader' => false,
'displayMode' => 'list',
'showAccountsIcons' => true,
'kickUserAfter' => '15',
'activeGroup' => 0,
'rememberActiveGroup' => true,
'defaultGroup' => 0,
'useEncryption' => false,
'defaultCaptureMode' => 'livescan',
'useDirectCapture' => false,
],
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Application Environment | Application Environment

View File

@ -91,7 +91,7 @@ public function testSubmitEmailPasswordRequest()
*/ */
public function testSubmitEmailPasswordRequestInDemoMode() public function testSubmitEmailPasswordRequestInDemoMode()
{ {
Config::set('app.options.isDemoApp', true); Config::set('2fauth.config.isDemoApp', true);
$response = $this->json('POST', '/api/password/email', [ $response = $this->json('POST', '/api/password/email', [
'email' => '' 'email' => ''

View File

@ -29,7 +29,7 @@ public function test2fauthResetDemowithoutDemoModeConsoleCommand()
*/ */
public function test2fauthResetDemowithConfirmConsoleCommand() public function test2fauthResetDemowithConfirmConsoleCommand()
{ {
Config::set('app.options.isDemoApp', true); Config::set('2fauth.config.isDemoApp', true);
$this->artisan('2fauth:reset-demo') $this->artisan('2fauth:reset-demo')
->expectsOutput('This will reset the app in order to run a clean and fresh demo.') ->expectsOutput('This will reset the app in order to run a clean and fresh demo.')
@ -119,7 +119,7 @@ public function test2fauthResetDemowithConfirmConsoleCommand()
*/ */
public function test2fauthResetDemowithBadConfirmationConsoleCommand() public function test2fauthResetDemowithBadConfirmationConsoleCommand()
{ {
Config::set('app.options.isDemoApp', true); Config::set('2fauth.config.isDemoApp', true);
$this->artisan('2fauth:reset-demo') $this->artisan('2fauth:reset-demo')
->expectsQuestion('To prevent any mistake please type the word "demo" to go on', 'null') ->expectsQuestion('To prevent any mistake please type the word "demo" to go on', 'null')
@ -135,7 +135,7 @@ public function test2fauthResetDemowithBadConfirmationConsoleCommand()
*/ */
public function test2fauthResetDemowithoutConfirmationConsoleCommand() public function test2fauthResetDemowithoutConfirmationConsoleCommand()
{ {
Config::set('app.options.isDemoApp', true); Config::set('2fauth.config.isDemoApp', true);
$this->artisan('2fauth:reset-demo --no-confirm') $this->artisan('2fauth:reset-demo --no-confirm')
->expectsOutput('Demo app refreshed') ->expectsOutput('Demo app refreshed')