Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to skip subscriber verification #1993

Merged
merged 5 commits into from
Jul 20, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should never need to read config from inside handlers.


/**
* 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