Use the Auth::user()->id throughout the controller. Closes #483

This commit is contained in:
James Brooks
2015-03-06 08:34:47 +00:00
parent ebaf7d8533
commit de9792b5fc
8 changed files with 13 additions and 10 deletions

View File

@@ -7,6 +7,7 @@ use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Cachet\Models\Tag;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
@@ -105,7 +106,9 @@ class DashComponentController extends Controller
public function updateComponentAction(Component $component)
{
$_component = Binput::get('component');
$_component['user_id'] = Auth::user()->id;
$tags = array_pull($_component, 'tags');
$component->update($_component);
if (! $component->isValid()) {
@@ -172,6 +175,7 @@ class DashComponentController extends Controller
public function createComponentAction()
{
$_component = Binput::get('component');
$_component['user_id'] = Auth::user()->id;
// We deal with tags separately.
$tags = array_pull($_component, 'tags');

View File

@@ -7,6 +7,7 @@ use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\IncidentTemplate;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
@@ -95,7 +96,9 @@ class DashIncidentController extends Controller
public function createIncidentAction()
{
$incidentData = Binput::get('incident');
$incidentData['user_id'] = Auth::user()->id;
$componentStatus = array_pull($incidentData, 'component_status');
$incident = Incident::create($incidentData);
if (! $incident->isValid()) {
@@ -261,8 +264,9 @@ class DashIncidentController extends Controller
*/
public function editIncidentAction(Incident $incident)
{
$_incident = Binput::get('incident');
$incident->update($_incident);
$incidentData = Binput::get('incident');
$incidentData['user_id'] = Auth::user()->id;
$incident->update($incidentData);
if (! $incident->isValid()) {
segment_track('Dashboard', [

View File

@@ -7,6 +7,7 @@ use CachetHQ\Cachet\Models\IncidentTemplate;
use Carbon\Carbon;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
use Illuminate\Support\MessageBag;
@@ -81,6 +82,7 @@ class DashScheduleController extends Controller
public function addScheduleAction()
{
$scheduleData = Binput::get('incident');
$scheduleData['user_id'] = Auth::user()->id;
// Parse the schedule date.
$scheduledAt = Carbon::createFromFormat('d/m/Y H:i', $scheduleData['scheduled_at']);
@@ -155,6 +157,7 @@ class DashScheduleController extends Controller
public function editScheduleAction(Incident $schedule)
{
$scheduleData = Binput::get('incident');
$scheduleData['user_id'] = Auth::user()->id
// Parse the schedule date.
$scheduledAt = Carbon::createFromFormat('d/m/Y H:i', $scheduleData['scheduled_at']);