Skip to content

Commit

Permalink
Added option to skip subscriber verification. Closes #1990
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrooksuk committed Jul 20, 2016
1 parent 0d90f04 commit 7f261a2
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -24,16 +26,24 @@ class SendSubscriberVerificationEmailHandler
*/
protected $mailer;

/**
* The illuminate config instance.
*
* @var \Illuminate\Contracts\Config\Repository
*/
protected $config;

/**
* Create a new send subscriber verification email handler.
*
* @param \Illuminate\Contracts\Mail\Mailer $mailer
*
* @return void
*/
public function __construct(MailQueue $mailer)
public function __construct(MailQueue $mailer, Repository $config)
{
$this->mailer = $mailer;
$this->config = $config;
}

/**
Expand All @@ -45,10 +55,17 @@ public function __construct(MailQueue $mailer)
*/
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([
Expand Down
11 changes: 11 additions & 0 deletions config/setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,15 @@
*/

'show_timezone' => false,

/*
|--------------------------------------------------------------------------
| Skip subscriber verifications
|--------------------------------------------------------------------------
|
| Whether to allow skipping of subscriber verifications.
|
*/

'skip_subscriber_verification' => false,
];
1 change: 1 addition & 0 deletions resources/lang/en/forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down
11 changes: 11 additions & 0 deletions resources/views/dashboard/settings/app-setup.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="checkbox">
<label>
<input type="hidden" value="0" name="skip_subscriber_verification">
<input type="checkbox" value="1" name="skip_subscriber_verification" {{ Config::get('setting.skip_subscriber_verification') ? 'checked' : null }}>
{{ trans('forms.settings.app-setup.skip_subscriber_verification') }}
</label>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="checkbox">
Expand Down

0 comments on commit 7f261a2

Please sign in to comment.