diff --git a/app/Bus/Handlers/Events/Subscriber/SendSubscriberVerificationEmailHandler.php b/app/Bus/Handlers/Events/Subscriber/SendSubscriberVerificationEmailHandler.php index 2ff98f02b0b1..306280dcfc1a 100644 --- a/app/Bus/Handlers/Events/Subscriber/SendSubscriberVerificationEmailHandler.php +++ b/app/Bus/Handlers/Events/Subscriber/SendSubscriberVerificationEmailHandler.php @@ -46,9 +46,9 @@ public function __construct(MailQueue $mailer) public function handle(SubscriberHasSubscribedEvent $event) { $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/app/Http/Controllers/Api/SubscriberController.php b/app/Http/Controllers/Api/SubscriberController.php index 42eeec094eb8..4d1793deb1a1 100644 --- a/app/Http/Controllers/Api/SubscriberController.php +++ b/app/Http/Controllers/Api/SubscriberController.php @@ -17,6 +17,7 @@ use CachetHQ\Cachet\Models\Subscriber; use CachetHQ\Cachet\Models\Subscription; use GrahamCampbell\Binput\Facades\Binput; +use Illuminate\Contracts\Config\Repository; use Illuminate\Database\QueryException; use Illuminate\Support\Facades\Request; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; @@ -48,12 +49,10 @@ public function getSubscribers() */ public function postSubscribers() { + $verified = Binput::get('verify', app(Repository::class)->get('setting.skip_subscriber_verification')); + try { - $subscriber = dispatch(new SubscribeSubscriberCommand( - Binput::get('email'), - Binput::get('verify', false), - Binput::get('components', null) - )); + $subscriber = dispatch(new SubscribeSubscriberCommand(Binput::get('email'), $verified, Binput::get('components'))); } catch (QueryException $e) { throw new BadRequestHttpException(); } diff --git a/app/Http/Controllers/Dashboard/SubscriberController.php b/app/Http/Controllers/Dashboard/SubscriberController.php index a62cd0b82367..9e1e6185d85b 100644 --- a/app/Http/Controllers/Dashboard/SubscriberController.php +++ b/app/Http/Controllers/Dashboard/SubscriberController.php @@ -16,6 +16,7 @@ use CachetHQ\Cachet\Bus\Commands\Subscriber\UnsubscribeSubscriberCommand; use CachetHQ\Cachet\Models\Subscriber; use GrahamCampbell\Binput\Facades\Binput; +use Illuminate\Contracts\Config\Repository; use Illuminate\Routing\Controller; use Illuminate\Support\Facades\Redirect; use Illuminate\Support\Facades\View; @@ -52,11 +53,13 @@ public function showAddSubscriber() */ public function createSubscriberAction() { + $verified = app(Repository::class)->get('setting.skip_subscriber_verification'); + try { $subscribers = preg_split("/\r\n|\n|\r/", Binput::get('email')); foreach ($subscribers as $subscriber) { - dispatch(new SubscribeSubscriberCommand($subscriber)); + dispatch(new SubscribeSubscriberCommand($subscriber, $verified)); } } catch (ValidationException $e) { return Redirect::route('dashboard.subscribers.add') diff --git a/app/Http/Controllers/SubscribeController.php b/app/Http/Controllers/SubscribeController.php index 14911a9215dc..f2ce15cadf1e 100644 --- a/app/Http/Controllers/SubscribeController.php +++ b/app/Http/Controllers/SubscribeController.php @@ -23,6 +23,7 @@ use CachetHQ\Cachet\Models\Subscription; use GrahamCampbell\Binput\Facades\Binput; use GrahamCampbell\Markdown\Facades\Markdown; +use Illuminate\Contracts\Config\Repository; use Illuminate\Routing\Controller; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Redirect; @@ -57,10 +58,9 @@ public function postSubscribe() { $email = Binput::get('email'); $subscriptions = Binput::get('subscriptions'); + $verified = app(Repository::class)->get('setting.skip_subscriber_verification'); try { - $verified = false; - $subscription = dispatch(new SubscribeSubscriberCommand($email, $verified)); } catch (ValidationException $e) { return Redirect::route('status-page') diff --git a/config/setting.php b/config/setting.php index 55fd970e756a..c17a6dee8135 100644 --- a/config/setting.php +++ b/config/setting.php @@ -77,4 +77,15 @@ */ '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 77c2afd80bdb..d6366b39ebfc 100644 --- a/resources/lang/en/forms.php +++ b/resources/lang/en/forms.php @@ -109,6 +109,7 @@ '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 7c9d4fb143a0..9a54c7ea101d 100644 --- a/resources/views/dashboard/settings/app-setup.blade.php +++ b/resources/views/dashboard/settings/app-setup.blade.php @@ -62,6 +62,17 @@ +