Jelajahi Sumber

Move options to config/2fauth

Bubka 3 tahun lalu
induk
melakukan
2cb4578109

+ 1 - 1
app/Http/Controllers/SettingController.php

@@ -140,7 +140,7 @@ class SettingController extends Controller
             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',

+ 2 - 2
app/Services/AppstractOptionsService.php

@@ -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 @@ class AppstractOptionsService implements SettingServiceInterface
         $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;
     }
     }

+ 29 - 0
config/2fauth.php

@@ -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,
+    ],
+
 ];
 ];

+ 0 - 22
config/app.php

@@ -24,28 +24,6 @@ return [
 
 
     '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

+ 1 - 1
tests/Feature/Auth/ForgotPasswordTest.php

@@ -91,7 +91,7 @@ class ForgotPasswordTest extends TestCase
      */
      */
     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' => ''

+ 3 - 3
tests/Feature/ConsoleTest.php

@@ -29,7 +29,7 @@ class ConsoleTest extends TestCase
      */
      */
     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 @@ class ConsoleTest extends TestCase
      */
      */
     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 @@ class ConsoleTest extends TestCase
      */
      */
     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')