فهرست منبع

Push to Error view when ProtectDB option fail

Bubka 4 سال پیش
والد
کامیت
289a208847
3فایلهای تغییر یافته به همراه16 افزوده شده و 17 حذف شده
  1. 13 10
      app/Http/Controllers/Settings/OptionController.php
  2. 1 5
      resources/js/views/settings/Options.vue
  3. 2 2
      resources/lang/en/errors.php

+ 13 - 10
app/Http/Controllers/Settings/OptionController.php

@@ -33,19 +33,22 @@ class OptionController extends Controller
         // The useEncryption option impacts the [existing] content of the database.
         // Encryption/Decryption of the data is done only if the user change the value of the option
         // to prevent successive encryption
-        
-        if( $request->useEncryption && !Options::get('useEncryption') ) {
 
-            // user enabled the encryption
-            if( !DbProtection::enable() ) {
-                return response()->json(['message' => __('errors.error_during_encryption'), 'settings' => Options::get()], 422);
+        if( isset($request->useEncryption))
+        {
+            if( $request->useEncryption && !Options::get('useEncryption') ) {
+
+                // user enabled the encryption
+                if( !DbProtection::enable() ) {
+                    return response()->json(['message' => __('errors.error_during_encryption'), 'settings' => Options::get()], 400);
+                }
             }
-        }
-        else if( !$request->useEncryption && Options::get('useEncryption') ) {
+            else if( !$request->useEncryption && Options::get('useEncryption') ) {
 
-            // user disabled the encryption
-            if( !DbProtection::disable() ) {
-                return response()->json(['message' => __('errors.error_during_decryption'), 'settings' => Options::get()], 422);
+                // user disabled the encryption
+                if( !DbProtection::disable() ) {
+                    return response()->json(['message' => __('errors.error_during_decryption'), 'settings' => Options::get()], 400);
+                }
             }
         }
 

+ 1 - 5
resources/js/views/settings/Options.vue

@@ -80,7 +80,7 @@
             handleSubmit(e) {
                 e.preventDefault()
 
-                this.form.post('/api/settings/options', {returnError: true})
+                this.form.post('/api/settings/options', {returnError: false})
                 .then(response => {
 
                     this.$notify({ type: 'is-success', text: response.data.message })
@@ -91,10 +91,6 @@
                     else {
                         this.$root.appSettings = response.data.settings
                     }
-                })
-                .catch(error => {
-                    
-                    this.$notify({ type: 'is-danger', text: error.response.data.message })
                 });
             },
 

+ 2 - 2
resources/lang/en/errors.php

@@ -25,7 +25,7 @@ return [
     'Unable_to_decrypt_uri' => 'Unable to decrypt uri',
     'not_a_supported_otp_type' => 'This OTP format is not currently supported',
     'wrong_current_password' => 'Wrong current password, nothing has changed',
-    'error_during_encryption' => 'Encryption failed, your database remains unprotected',
-    'error_during_decryption' => 'Decryption failed, your database is still protected',
+    'error_during_encryption' => 'Encryption failed, your database remains unprotected.',
+    'error_during_decryption' => 'Decryption failed, your database is still protected. This is mainly caused by an integrity issue of encrypted data for one or more accounts.',
 
 ];