Forráskód Böngészése

Updated modal rows

Will Browning 6 éve
szülő
commit
7f8159425f

+ 1 - 1
app/Console/Commands/ReceiveEmail.php

@@ -187,7 +187,7 @@ class ReceiveEmail extends Command
         $emailData = new EmailData($this->parser);
 
         $alias->recipientsUsingPgp()->each(function ($recipient) use ($alias, $emailData) {
-            $message = (new ForwardEmail($alias, $emailData, $recipient->should_encrypt, $recipient->fingerprint))->onQueue('default');
+            $message = (new ForwardEmail($alias, $emailData, $recipient->fingerprint))->onQueue('default');
 
             Mail::to($recipient->email)->queue($message);
         });

+ 0 - 9
app/Http/Controllers/AliasRecipientController.php

@@ -15,13 +15,4 @@ class AliasRecipientController extends Controller
 
         return new AliasResource($alias);
     }
-
-    public function destroy($id)
-    {
-        $aliasRecipient = user()->aliasRecipients()->findOrFail($id);
-
-        $aliasRecipient->delete();
-
-        return response('', 204);
-    }
 }

+ 2 - 1
app/Http/Controllers/Auth/VerificationController.php

@@ -39,7 +39,8 @@ class VerificationController extends Controller
     {
         $this->middleware('auth');
         $this->middleware('signed')->only('verify');
-        $this->middleware('throttle:1,5')->only('verify', 'resend');
+        $this->middleware('throttle:1,5')->only('resend');
+        $this->middleware('throttle:60,1')->only('verify');
     }
 
     /**

+ 0 - 2
app/Http/Controllers/RecipientController.php

@@ -34,8 +34,6 @@ class RecipientController extends Controller
 
         $recipient = user()->recipients()->findOrFail($id);
 
-        $recipient->aliases()->detach();
-
         $recipient->delete();
 
         return response('', 204);

+ 1 - 1
app/Jobs/DeleteAccount.php

@@ -38,7 +38,7 @@ class DeleteAccount implements ShouldQueue
         $this->user->aliasRecipients()->delete();
         $this->user->aliases()->whereNull('domain_id')->forceDelete();
         $this->user->aliases()->delete();
-        $this->user->recipients()->delete();
+        $this->user->recipients()->get()->each->delete(); // in order to fire deleting model event
         $this->user->domains()->delete();
         $this->user->delete();
     }

+ 5 - 7
app/Mail/ForwardEmail.php

@@ -25,7 +25,7 @@ class ForwardEmail extends Mailable implements ShouldQueue
     protected $emailAttachments;
     protected $deactivateUrl;
     protected $bannerLocation;
-    protected $shouldEncrypt;
+    protected $fingerprint;
     protected $openpgpsigner;
 
     /**
@@ -33,7 +33,7 @@ class ForwardEmail extends Mailable implements ShouldQueue
      *
      * @return void
      */
-    public function __construct(Alias $alias, EmailData $emailData, $shouldEncrypt = false, $fingerprint = null)
+    public function __construct(Alias $alias, EmailData $emailData, $fingerprint = null)
     {
         $this->alias = $alias;
         $this->sender = $emailData->sender;
@@ -44,11 +44,9 @@ class ForwardEmail extends Mailable implements ShouldQueue
         $this->emailAttachments = $emailData->attachments;
         $this->deactivateUrl = URL::signedRoute('deactivate', ['alias' => $alias->id]);
         $this->bannerLocation = $this->alias->user->banner_location;
-        $this->shouldEncrypt = $shouldEncrypt;
 
-        if ($shouldEncrypt) {
-            $this->openpgpsigner = OpenPGPSigner::newInstance(config('anonaddy.signing_key_fingerprint'), [], "~/.gnupg");
-            $this->openpgpsigner->addRecipient($fingerprint);
+        if ($this->fingerprint = $fingerprint) {
+            $this->openpgpsigner = OpenPGPSigner::newInstance(config('anonaddy.signing_key_fingerprint'), [$fingerprint], "~/.gnupg");
         }
     }
 
@@ -81,7 +79,7 @@ class ForwardEmail extends Mailable implements ShouldQueue
                 $message->getHeaders()
                         ->addTextHeader('Return-Path', 'bounces@anonaddy.me');
 
-                if ($this->shouldEncrypt) {
+                if ($this->fingerprint) {
                     $message->attachSigner($this->openpgpsigner);
                 }
             });

+ 14 - 0
app/Recipient.php

@@ -40,6 +40,20 @@ class Recipient extends Model
         'should_encrypt' => 'boolean'
     ];
 
+    public static function boot()
+    {
+        parent::boot();
+
+        Recipient::deleting(function ($recipient) {
+            if ($recipient->fingerprint) {
+                $gnupg = new \gnupg();
+                $gnupg->deletekey($recipient->fingerprint);
+            }
+
+            $recipient->aliases()->detach();
+        });
+    }
+
     /**
      * Get the user the recipient belongs to.
      */

+ 17 - 10
composer.lock

@@ -1161,16 +1161,16 @@
         },
         {
             "name": "nesbot/carbon",
-            "version": "2.20.0",
+            "version": "2.21.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/briannesbitt/Carbon.git",
-                "reference": "bc671b896c276795fad8426b0aa24e8ade0f2498"
+                "reference": "da6410b77f74eecd98d24ffb6dfecefccf3ca17f"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/bc671b896c276795fad8426b0aa24e8ade0f2498",
-                "reference": "bc671b896c276795fad8426b0aa24e8ade0f2498",
+                "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/da6410b77f74eecd98d24ffb6dfecefccf3ca17f",
+                "reference": "da6410b77f74eecd98d24ffb6dfecefccf3ca17f",
                 "shasum": ""
             },
             "require": {
@@ -1186,6 +1186,9 @@
                 "phpunit/phpunit": "^7.5 || ^8.0",
                 "squizlabs/php_codesniffer": "^3.4"
             },
+            "bin": [
+                "bin/carbon"
+            ],
             "type": "library",
             "extra": {
                 "laravel": {
@@ -1208,6 +1211,10 @@
                     "name": "Brian Nesbitt",
                     "email": "brian@nesbot.com",
                     "homepage": "http://nesbot.com"
+                },
+                {
+                    "name": "kylekatarnls",
+                    "homepage": "http://github.com/kylekatarnls"
                 }
             ],
             "description": "A simple API extension for DateTime.",
@@ -1217,7 +1224,7 @@
                 "datetime",
                 "time"
             ],
-            "time": "2019-06-25T10:00:57+00:00"
+            "time": "2019-07-14T17:06:46+00:00"
         },
         {
             "name": "nikic/php-parser",
@@ -5023,16 +5030,16 @@
         },
         {
             "name": "phpunit/phpunit",
-            "version": "8.2.4",
+            "version": "8.2.5",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/phpunit.git",
-                "reference": "25fe0b5031b24722f66a75ad479a074cccc1bb37"
+                "reference": "c1b8534b3730f20f58600124129197bf1183dc92"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/25fe0b5031b24722f66a75ad479a074cccc1bb37",
-                "reference": "25fe0b5031b24722f66a75ad479a074cccc1bb37",
+                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c1b8534b3730f20f58600124129197bf1183dc92",
+                "reference": "c1b8534b3730f20f58600124129197bf1183dc92",
                 "shasum": ""
             },
             "require": {
@@ -5102,7 +5109,7 @@
                 "testing",
                 "xunit"
             ],
-            "time": "2019-07-03T08:30:33+00:00"
+            "time": "2019-07-15T06:26:24+00:00"
         },
         {
             "name": "sebastian/code-unit-reverse-lookup",

+ 1 - 1
resources/js/pages/Recipients.vue

@@ -301,7 +301,7 @@
             class="w-full appearance-none bg-grey-100 border border-transparent text-grey-700 focus:outline-none rounded p-3 mb-6"
             :class="errors.recipientKey ? 'border-red-500' : ''"
             placeholder="Begins with '-----BEGIN PGP PUBLIC KEY BLOCK-----'"
-            rows="15"
+            rows="10"
             autofocus
           >
           </textarea>