Skip to content

Commit

Permalink
Merge pull request #1993 from CachetHQ/skip-subscriber-verification
Browse files Browse the repository at this point in the history
Added option to skip subscriber verification
  • Loading branch information
joecohens authored Jul 20, 2016
2 parents 0d90f04 + ef694b0 commit ef9f7d2
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
9 changes: 4 additions & 5 deletions app/Http/Controllers/Api/SubscriberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down
5 changes: 4 additions & 1 deletion app/Http/Controllers/Dashboard/SubscriberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/SubscribeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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')
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 ef9f7d2

Please sign in to comment.