From 7f261a218a0717ff38d0c9551b7568c4021b6a1d Mon Sep 17 00:00:00 2001 From: James Brooks Date: Wed, 20 Jul 2016 16:00:27 +0100 Subject: [PATCH] Added option to skip subscriber verification. Closes #1990 --- ...SendSubscriberVerificationEmailHandler.php | 25 ++++++++++++++++--- config/setting.php | 11 ++++++++ resources/lang/en/forms.php | 1 + .../dashboard/settings/app-setup.blade.php | 11 ++++++++ 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/app/Bus/Handlers/Events/Subscriber/SendSubscriberVerificationEmailHandler.php b/app/Bus/Handlers/Events/Subscriber/SendSubscriberVerificationEmailHandler.php index 2ff98f02b..b225c679c 100644 --- a/app/Bus/Handlers/Events/Subscriber/SendSubscriberVerificationEmailHandler.php +++ b/app/Bus/Handlers/Events/Subscriber/SendSubscriberVerificationEmailHandler.php @@ -11,7 +11,9 @@ namespace CachetHQ\Cachet\Bus\Handlers\Events\Subscriber; +use CachetHQ\Cachet\Bus\Commands\Subscriber\VerifySubscriberCommand; use CachetHQ\Cachet\Bus\Events\Subscriber\SubscriberHasSubscribedEvent; +use Illuminate\Contracts\Config\Repository; use Illuminate\Contracts\Mail\MailQueue; use Illuminate\Mail\Message; @@ -24,6 +26,13 @@ class SendSubscriberVerificationEmailHandler */ protected $mailer; + /** + * The illuminate config instance. + * + * @var \Illuminate\Contracts\Config\Repository + */ + protected $config; + /** * Create a new send subscriber verification email handler. * @@ -31,9 +40,10 @@ class SendSubscriberVerificationEmailHandler * * @return void */ - public function __construct(MailQueue $mailer) + public function __construct(MailQueue $mailer, Repository $config) { $this->mailer = $mailer; + $this->config = $config; } /** @@ -45,10 +55,17 @@ class SendSubscriberVerificationEmailHandler */ public function handle(SubscriberHasSubscribedEvent $event) { + // If we've enabled verification skipping, then just verify the subscriber right now. + if ($this->config->get('setting.skip_subscriber_verification')) { + dispatch(new VerifySubscriberCommand($event->subscriber)); + + return; + } + $mail = [ - 'email' => $event->subscriber->email, - 'subject' => 'Confirm your subscription.', - 'link' => route('subscribe.verify', ['code' => $event->subscriber->verify_code]), + 'email' => $event->subscriber->email, + 'subject' => 'Confirm your subscription.', + 'link' => route('subscribe.verify', ['code' => $event->subscriber->verify_code]), ]; $this->mailer->queue([ diff --git a/config/setting.php b/config/setting.php index 55fd970e7..c17a6dee8 100644 --- a/config/setting.php +++ b/config/setting.php @@ -77,4 +77,15 @@ return [ */ 'show_timezone' => false, + + /* + |-------------------------------------------------------------------------- + | Skip subscriber verifications + |-------------------------------------------------------------------------- + | + | Whether to allow skipping of subscriber verifications. + | + */ + + 'skip_subscriber_verification' => false, ]; diff --git a/resources/lang/en/forms.php b/resources/lang/en/forms.php index 77c2afd80..d6366b39e 100644 --- a/resources/lang/en/forms.php +++ b/resources/lang/en/forms.php @@ -109,6 +109,7 @@ return [ 'banner' => 'Banner Image', 'banner-help' => "It's recommended that you upload files no bigger than 930px wide .", 'subscribers' => 'Allow people to signup to email notifications?', + 'skip_subscriber_verification' => 'Skip verifying of users? (Be warned, you could be spammed)', 'automatic_localization' => 'Automatically localise your status page to your visitor\'s language?', 'enable_external_dependencies' => 'Enable Third Party Dependencies (Google Fonts, Trackers, etc...)', 'show_timezone' => 'Show the timezone the status page is running in.', diff --git a/resources/views/dashboard/settings/app-setup.blade.php b/resources/views/dashboard/settings/app-setup.blade.php index 7c9d4fb14..9a54c7ea1 100644 --- a/resources/views/dashboard/settings/app-setup.blade.php +++ b/resources/views/dashboard/settings/app-setup.blade.php @@ -62,6 +62,17 @@ +
+
+
+ +
+
+