From dbc488b6b7171ea860ba8afc554b68d5371d1cba Mon Sep 17 00:00:00 2001 From: James Brooks Date: Sat, 8 Oct 2016 10:36:54 +0100 Subject: [PATCH 1/4] Don't use the config facade and redirect to the route --- app/Http/Middleware/SetupAlreadyCompleted.php | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/app/Http/Middleware/SetupAlreadyCompleted.php b/app/Http/Middleware/SetupAlreadyCompleted.php index 96db9729f5f3..69ba78ff0a83 100644 --- a/app/Http/Middleware/SetupAlreadyCompleted.php +++ b/app/Http/Middleware/SetupAlreadyCompleted.php @@ -16,8 +16,34 @@ use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Redirect; +/** + * This is the setup already completed middelware class. + * + * @author Graham Campbell + * @author James Brooks + * @author Joseph Cohen + */ class SetupAlreadyCompleted { + /** + * The config repository instance. + * + * @var \Illuminate\Contracts\Config\Repository + */ + protected $config; + + /** + * Creates a new setup already completed middleware instance. + * + * @param \Illuminate\Contracts\Config\Repository $config + * + * @return void + */ + public function __construct(Repository $config) + { + $this->config = $config; + } + /** * Handle an incoming request. * @@ -28,8 +54,8 @@ class SetupAlreadyCompleted */ public function handle(Request $request, Closure $next) { - if (Config::get('setting.app_name')) { - return Redirect::to('dashboard'); + if ($this->config->get('setting.app_name')) { + return Redirect::route('dashboard.index'); } return $next($request); From 96c0444783ff54735f5d98c559507781dd078d8b Mon Sep 17 00:00:00 2001 From: James Brooks Date: Sat, 8 Oct 2016 10:37:21 +0100 Subject: [PATCH 2/4] Added middleware class headers --- app/Http/Middleware/Acceptable.php | 6 ++++++ app/Http/Middleware/Admin.php | 7 +++++++ app/Http/Middleware/ApiAuthentication.php | 7 +++++++ app/Http/Middleware/Authenticate.php | 7 +++++++ app/Http/Middleware/Localize.php | 7 +++++++ app/Http/Middleware/ReadyForUse.php | 7 +++++++ app/Http/Middleware/RedirectIfAuthenticated.php | 7 +++++++ app/Http/Middleware/SubscribersConfigured.php | 6 ++++++ app/Http/Middleware/Timezone.php | 6 ++++++ 9 files changed, 60 insertions(+) diff --git a/app/Http/Middleware/Acceptable.php b/app/Http/Middleware/Acceptable.php index 2c22a6a21e26..7db13506338d 100644 --- a/app/Http/Middleware/Acceptable.php +++ b/app/Http/Middleware/Acceptable.php @@ -15,6 +15,12 @@ use Illuminate\Http\Request; use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException; +/** + * This is the acceptable middleware class. + * + * @author Graham Campbell + * @author James Brooks + */ class Acceptable { /** diff --git a/app/Http/Middleware/Admin.php b/app/Http/Middleware/Admin.php index 5088b091ac20..5c83c82141e8 100644 --- a/app/Http/Middleware/Admin.php +++ b/app/Http/Middleware/Admin.php @@ -16,6 +16,13 @@ use Illuminate\Http\Request; use Symfony\Component\HttpKernel\Exception\HttpException; +/** + * This is the admin middleware class. + * + * @author Joseph Cohen + * @author Graham Campbell + * @author James Brooks + */ class Admin { /** diff --git a/app/Http/Middleware/ApiAuthentication.php b/app/Http/Middleware/ApiAuthentication.php index f4c10611d6f4..0ae7a0683aad 100644 --- a/app/Http/Middleware/ApiAuthentication.php +++ b/app/Http/Middleware/ApiAuthentication.php @@ -18,6 +18,13 @@ use Illuminate\Http\Request; use Symfony\Component\HttpKernel\Exception\HttpException; +/** + * This is the api authentication middleware class. + * + * @author Joseph Cohen + * @author Graham Campbell + * @author James Brooks + */ class ApiAuthentication { /** diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 0400413194c2..6139df30c200 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -16,6 +16,13 @@ use Illuminate\Http\Request; use Symfony\Component\HttpKernel\Exception\HttpException; +/** + * This is the authenticate middleware class. + * + * @author Joseph Cohen + * @author Graham Campbell + * @author James Brooks + */ class Authenticate { /** diff --git a/app/Http/Middleware/Localize.php b/app/Http/Middleware/Localize.php index 718e2ddb74d2..62948a855966 100644 --- a/app/Http/Middleware/Localize.php +++ b/app/Http/Middleware/Localize.php @@ -16,6 +16,13 @@ use Illuminate\Http\Request; use Jenssegers\Date\Date; +/** + * This is the localize middleware class. + * + * @author James Brooks + * @author Joseph Cohen + * @author Graham Campbell + */ class Localize { /** diff --git a/app/Http/Middleware/ReadyForUse.php b/app/Http/Middleware/ReadyForUse.php index 364c7f42a50d..b6c33281607b 100644 --- a/app/Http/Middleware/ReadyForUse.php +++ b/app/Http/Middleware/ReadyForUse.php @@ -17,6 +17,13 @@ use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Redirect; +/** + * This is the ready for use middleware class. + * + * @author Graham Campbell + * @author James Brooks + * @author Joseph Cohen + */ class ReadyForUse { /** diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index 7b79128b3a20..57f5958e6b59 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -16,6 +16,13 @@ use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; +/** + * This is the redirect if authenticated middleware class. + * + * @author Graham Campbell + * @author Joseph Cohen + * @author James Brooks + */ class RedirectIfAuthenticated { /** diff --git a/app/Http/Middleware/SubscribersConfigured.php b/app/Http/Middleware/SubscribersConfigured.php index 50cdeedb6edf..d549555f68fc 100644 --- a/app/Http/Middleware/SubscribersConfigured.php +++ b/app/Http/Middleware/SubscribersConfigured.php @@ -15,6 +15,12 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Redirect; +/** + * This is the subscribers configured middleware class. + * + * @author James Brooks + * @author Graham Campbell + */ class SubscribersConfigured { /** diff --git a/app/Http/Middleware/Timezone.php b/app/Http/Middleware/Timezone.php index 8b56ddbbdbee..40afe9e066a7 100644 --- a/app/Http/Middleware/Timezone.php +++ b/app/Http/Middleware/Timezone.php @@ -15,6 +15,12 @@ use Illuminate\Contracts\Config\Repository; use Illuminate\Http\Request; +/** + * This is the timezone middleware class. + * + * @author James Brooks + * @author Graham Campbell + */ class Timezone { /** From 4f807e6d936a5a0f0b627446a39f26796522c58a Mon Sep 17 00:00:00 2001 From: James Brooks Date: Sat, 8 Oct 2016 10:44:37 +0100 Subject: [PATCH 3/4] Fix imports --- app/Http/Middleware/SetupAlreadyCompleted.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Middleware/SetupAlreadyCompleted.php b/app/Http/Middleware/SetupAlreadyCompleted.php index 69ba78ff0a83..d8d664ef084a 100644 --- a/app/Http/Middleware/SetupAlreadyCompleted.php +++ b/app/Http/Middleware/SetupAlreadyCompleted.php @@ -12,8 +12,8 @@ namespace CachetHQ\Cachet\Http\Middleware; use Closure; +use Illuminate\Contracts\Config\Repository; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Redirect; /** From dfeab93d88cb0f42ca21569dfec0cdce698a8b66 Mon Sep 17 00:00:00 2001 From: James Brooks Date: Sat, 8 Oct 2016 11:01:19 +0100 Subject: [PATCH 4/4] Remove references to component in the Maintenance emails. Fixes #2153 --- .../Incident/SendMaintenanceEmailNotificationHandler.php | 2 -- resources/views/emails/incidents/maintenance-html.blade.php | 2 +- resources/views/emails/incidents/maintenance-text.blade.php | 3 --- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/app/Bus/Handlers/Events/Incident/SendMaintenanceEmailNotificationHandler.php b/app/Bus/Handlers/Events/Incident/SendMaintenanceEmailNotificationHandler.php index d87abf6a8ae3..c9a12462d416 100644 --- a/app/Bus/Handlers/Events/Incident/SendMaintenanceEmailNotificationHandler.php +++ b/app/Bus/Handlers/Events/Incident/SendMaintenanceEmailNotificationHandler.php @@ -110,8 +110,6 @@ public function notify(MaintenanceWasScheduledEvent $event, $subscriber) 'subject' => trans('cachet.subscriber.email.maintenance.subject', [ 'name' => $incident->name, ]), - 'has_component' => ($event->incident->component) ? true : false, - 'component_name' => $component ? $component->name : null, 'name' => $incident->name, 'timestamp' => $incident->scheduled_at_formatted, 'status' => $incident->human_status, diff --git a/resources/views/emails/incidents/maintenance-html.blade.php b/resources/views/emails/incidents/maintenance-html.blade.php index c30598c001b9..b521492502ba 100644 --- a/resources/views/emails/incidents/maintenance-html.blade.php +++ b/resources/views/emails/incidents/maintenance-html.blade.php @@ -7,7 +7,7 @@

- {!! $status !!} @if($has_component) ({{ $component_name }}) @endif + {!! $status !!} {!! $html_content !!} {!! $timestamp !!}

diff --git a/resources/views/emails/incidents/maintenance-text.blade.php b/resources/views/emails/incidents/maintenance-text.blade.php index 0702491199ec..6c2d54bbfc27 100644 --- a/resources/views/emails/incidents/maintenance-text.blade.php +++ b/resources/views/emails/incidents/maintenance-text.blade.php @@ -4,9 +4,6 @@ {!! $text_content !!} {!! $timestamp !!} -@if($has_component) -({{ $component_name }}) -@endif {!! trans('cachet.subscriber.email.manage') !!} {{ $manage_link }} {!! trans('cachet.subscriber.email.unsubscribe') !!} {{ $unsubscribe_link }}