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

Fixed redirects with “cachet_redirect” helper #2176

Merged
merged 15 commits into from
Oct 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions app/Http/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function postLogin()
if (Auth::user()->hasTwoFactor) {
Session::put('2fa_id', Auth::user()->id);

return cachet_route('auth.two-factor');
return cachet_redirect('auth.two-factor');
}

Auth::attempt($loginData, $rememberUser);
Expand All @@ -68,7 +68,7 @@ public function postLogin()
return Redirect::intended(cachet_route('dashboard'));
}

return cachet_route('auth.login')
return cachet_redirect('auth.login')
->withInput(Binput::except('password'))
->withError(trans('forms.login.invalid'));
}
Expand Down Expand Up @@ -113,11 +113,11 @@ public function postTwoFactor()
// Failed login, log back out.
Auth::logout();

return cachet_route('auth.login')->withError(trans('forms.login.invalid-token'));
return cachet_redirect('auth.login')->withError(trans('forms.login.invalid-token'));
}
}

return cachet_route('auth.login')->withError(trans('forms.login.invalid-token'));
return cachet_redirect('auth.login')->withError(trans('forms.login.invalid-token'));
}

/**
Expand Down
20 changes: 10 additions & 10 deletions app/Http/Controllers/Dashboard/ComponentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function updateComponentAction(Component $component)
$componentData['enabled']
));
} catch (ValidationException $e) {
return cachet_route('dashboard.components.edit', [$component->id])
return cachet_redirect('dashboard.components.edit', [$component->id])
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.edit.failure')))
->withErrors($e->getMessageBag());
Expand All @@ -153,7 +153,7 @@ public function updateComponentAction(Component $component)

$component->tags()->sync($componentTags);

return cachet_route('dashboard.components.edit', [$component->id])
return cachet_redirect('dashboard.components.edit', [$component->id])
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.edit.success')));
}

Expand Down Expand Up @@ -190,7 +190,7 @@ public function createComponentAction()
$componentData['enabled']
));
} catch (ValidationException $e) {
return cachet_route('dashboard.components.create')
return cachet_redirect('dashboard.components.create')
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.add.failure')))
->withErrors($e->getMessageBag());
Expand All @@ -206,7 +206,7 @@ public function createComponentAction()

$component->tags()->sync($componentTags);

return cachet_route('dashboard.components')
return cachet_redirect('dashboard.components')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.add.success')));
}

Expand All @@ -221,7 +221,7 @@ public function deleteComponentAction(Component $component)
{
dispatch(new RemoveComponentCommand($component));

return cachet_route('dashboard.components')
return cachet_redirect('dashboard.components')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.delete.success')));
}

Expand All @@ -236,7 +236,7 @@ public function deleteComponentGroupAction(ComponentGroup $group)
{
dispatch(new RemoveComponentGroupCommand($group));

return cachet_route('dashboard.components.groups')
return cachet_redirect('dashboard.components.groups')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.delete.success')));
}

Expand Down Expand Up @@ -280,13 +280,13 @@ public function postAddComponentGroup()
Binput::get('visible')
));
} catch (ValidationException $e) {
return cachet_route('dashboard.components.groups.create')
return cachet_redirect('dashboard.components.groups.create')
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.groups.add.failure')))
->withErrors($e->getMessageBag());
}

return cachet_route('dashboard.components.groups')
return cachet_redirect('dashboard.components.groups')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.groups.add.success')));
}

Expand All @@ -308,13 +308,13 @@ public function updateComponentGroupAction(ComponentGroup $group)
Binput::get('visible')
));
} catch (ValidationException $e) {
return cachet_route('dashboard.components.groups.edit', [$group->id])
return cachet_redirect('dashboard.components.groups.edit', [$group->id])
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.groups.edit.failure')))
->withErrors($e->getMessageBag());
}

return cachet_route('dashboard.components.groups.edit', [$group->id])
return cachet_redirect('dashboard.components.groups.edit', [$group->id])
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.groups.edit.success')));
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/Dashboard/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function __construct(Feed $feed, Guard $guard)
*/
public function redirectAdmin()
{
return cachet_route('dashboard');
return cachet_redirect('dashboard');
}

/**
Expand Down
24 changes: 12 additions & 12 deletions app/Http/Controllers/Dashboard/IncidentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ public function createIncidentAction()
null
));
} catch (ValidationException $e) {
return cachet_route('dashboard.incidents.create')
return cachet_redirect('dashboard.incidents.create')
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.add.failure')))
->withErrors($e->getMessageBag());
}

return cachet_route('dashboard.incidents')
return cachet_redirect('dashboard.incidents')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.add.success')));
}

Expand Down Expand Up @@ -184,7 +184,7 @@ public function deleteTemplateAction(IncidentTemplate $template)
{
$template->delete();

return cachet_route('dashboard.templates')
return cachet_redirect('dashboard.templates')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.templates.delete.success')));
}

Expand All @@ -198,13 +198,13 @@ public function createIncidentTemplateAction()
try {
IncidentTemplate::create(Binput::get('template'));
} catch (ValidationException $e) {
return cachet_route('dashboard.templates.create')
return cachet_redirect('dashboard.templates.create')
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.add.failure')))
->withErrors($e->getMessageBag());
}

return cachet_route('dashboard.templates')
return cachet_redirect('dashboard.templates')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.templates.add.success')));
}

Expand All @@ -219,7 +219,7 @@ public function deleteIncidentAction(Incident $incident)
{
dispatch(new RemoveIncidentCommand($incident));

return cachet_route('dashboard.incidents')
return cachet_redirect('dashboard.incidents')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.delete.success')));
}

Expand Down Expand Up @@ -264,7 +264,7 @@ public function editIncidentAction(Incident $incident)
null
));
} catch (ValidationException $e) {
return cachet_route('dashboard.incidents.edit', ['id' => $incident->id])
return cachet_redirect('dashboard.incidents.edit', ['id' => $incident->id])
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure')))
->withErrors($e->getMessageBag());
Expand All @@ -274,7 +274,7 @@ public function editIncidentAction(Incident $incident)
$incident->component->update(['status' => Binput::get('component_status')]);
}

return cachet_route('dashboard.incidents.edit', ['id' => $incident->id])
return cachet_redirect('dashboard.incidents.edit', ['id' => $incident->id])
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.edit.success')));
}

Expand All @@ -290,12 +290,12 @@ public function editTemplateAction(IncidentTemplate $template)
try {
$template->update(Binput::get('template'));
} catch (ValidationException $e) {
return cachet_route('dashboard.templates.edit', ['id' => $template->id])
return cachet_redirect('dashboard.templates.edit', ['id' => $template->id])
->withUpdatedTemplate($template)
->withTemplateErrors($e->getMessageBag()->getErrors());
}

return cachet_route('dashboard.templates.edit', ['id' => $template->id])
return cachet_redirect('dashboard.templates.edit', ['id' => $template->id])
->withUpdatedTemplate($template);
}

Expand Down Expand Up @@ -328,13 +328,13 @@ public function createIncidentUpdateAction(Incident $incident)
$this->auth->user()
));
} catch (ValidationException $e) {
return cachet_route('dashboard.incidents.update', ['id' => $incident->id])
return cachet_redirect('dashboard.incidents.update', ['id' => $incident->id])
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure')))
->withErrors($e->getMessageBag());
}

return cachet_route('dashboard.incidents')
return cachet_redirect('dashboard.incidents')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.delete.success')));
}
}
10 changes: 5 additions & 5 deletions app/Http/Controllers/Dashboard/MetricController.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ public function createMetricAction()
$metricData['threshold']
));
} catch (ValidationException $e) {
return cachet_route('dashboard.metrics.create')
return cachet_redirect('dashboard.metrics.create')
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.metrics.add.failure')))
->withErrors($e->getMessageBag());
}

return cachet_route('dashboard.metrics')
return cachet_redirect('dashboard.metrics')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.add.success')));
}

Expand All @@ -114,7 +114,7 @@ public function deleteMetricAction(Metric $metric)
{
dispatch(new RemoveMetricCommand($metric));

return cachet_route('dashboard.metrics')
return cachet_redirect('dashboard.metrics')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.delete.success')));
}

Expand Down Expand Up @@ -155,13 +155,13 @@ public function editMetricAction(Metric $metric)
Binput::get('threshold', null, false)
));
} catch (ValidationException $e) {
return cachet_route('dashboard.metrics.edit', [$metric->id])
return cachet_redirect('dashboard.metrics.edit', [$metric->id])
->withInput(Binput::all())
->withTitle(sprintf('<strong>%s</strong>', trans('dashboard.notifications.whoops')))
->withErrors($e->getMessageBag());
}

return cachet_route('dashboard.metrics.edit', [$metric->id])
return cachet_redirect('dashboard.metrics.edit', [$metric->id])
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.edit.success')));
}
}
12 changes: 6 additions & 6 deletions app/Http/Controllers/Dashboard/ScheduleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ public function addScheduleAction()
Binput::get('scheduled_at')
));
} catch (ValidationException $e) {
return cachet_route('dashboard.schedule.create')
return cachet_redirect('dashboard.schedule.create')
->withInput(Binput::all())
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.add.failure')))
->withErrors($e->getMessageBag());
}

return cachet_route('dashboard.schedule')
return cachet_redirect('dashboard.schedule')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.add.success')));
}

Expand Down Expand Up @@ -145,7 +145,7 @@ public function editScheduleAction(Incident $schedule)
$messageBag = new MessageBag();
$messageBag->add('scheduled_at', trans('validation.date', ['attribute' => 'scheduled time you supplied']));

return cachet_route('dashboard.schedule.edit', [$schedule->id])->withErrors($messageBag);
return cachet_redirect('dashboard.schedule.edit', [$schedule->id])->withErrors($messageBag);
}

$scheduleData['scheduled_at'] = $scheduledAt;
Expand All @@ -155,13 +155,13 @@ public function editScheduleAction(Incident $schedule)
try {
$schedule->update($scheduleData);
} catch (ValidationException $e) {
return cachet_route('dashboard.schedule.edit', [$schedule->id])
return cachet_redirect('dashboard.schedule.edit', [$schedule->id])
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.edit.failure')))
->withErrors($e->getMessageBag());
}

return cachet_route('dashboard.schedule.edit', [$schedule->id])
return cachet_redirect('dashboard.schedule.edit', [$schedule->id])
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.edit.success')));
}

Expand All @@ -176,7 +176,7 @@ public function deleteScheduleAction(Incident $schedule)
{
$schedule->delete();

return cachet_route('dashboard.schedule')
return cachet_redirect('dashboard.schedule')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.delete.success')));
}
}
6 changes: 3 additions & 3 deletions app/Http/Controllers/Dashboard/SubscriberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ public function createSubscriberAction()
dispatch(new SubscribeSubscriberCommand($subscriber, $verified));
}
} catch (ValidationException $e) {
return cachet_route('dashboard.subscribers.create')
return cachet_redirect('dashboard.subscribers.create')
->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.subscribers.add.failure')))
->withErrors($e->getMessageBag());
}

return cachet_route('dashboard.subscribers.create')
return cachet_redirect('dashboard.subscribers.create')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.subscribers.add.success')));
}

Expand All @@ -84,6 +84,6 @@ public function deleteSubscriberAction(Subscriber $subscriber)
{
dispatch(new UnsubscribeSubscriberCommand($subscriber));

return cachet_route('dashboard.subscribers');
return cachet_redirect('dashboard.subscribers');
}
}
14 changes: 7 additions & 7 deletions app/Http/Controllers/Dashboard/TeamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ public function postAddUser()
Binput::get('level')
));
} catch (ValidationException $e) {
return cachet_route('dashboard.team.create')
return cachet_redirect('dashboard.team.create')
->withInput(Binput::except('password'))
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.add.failure')))
->withErrors($e->getMessageBag());
}

return cachet_route('dashboard.team.create')
return cachet_redirect('dashboard.team.create')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.add.success')));
}

Expand All @@ -111,13 +111,13 @@ public function postUpdateUser(User $user)
try {
$user->update($userData);
} catch (ValidationException $e) {
return cachet_route('dashboard.team.edit', [$user->id])
return cachet_redirect('dashboard.team.edit', [$user->id])
->withInput($userData)
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure')))
->withErrors($e->getMessageBag());
}

return cachet_route('dashboard.team.edit', [$user->id])
return cachet_redirect('dashboard.team.edit', [$user->id])
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.edit.success')));
}

Expand All @@ -133,13 +133,13 @@ public function postInviteUser()
array_unique(array_filter((array) Binput::get('emails')))
));
} catch (ValidationException $e) {
return cachet_route('dashboard.team.invite')
return cachet_redirect('dashboard.team.invite')
->withInput(Binput::except('password'))
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.invite.failure')))
->withErrors($e->getMessageBag());
}

return cachet_route('dashboard.team.invite')
return cachet_redirect('dashboard.team.invite')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.invite.success')));
}

Expand All @@ -154,7 +154,7 @@ public function deleteUser(User $user)
{
dispatch(new RemoveUserCommand($user));

return cachet_route('dashboard.team')
return cachet_redirect('dashboard.team')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.delete.success')));
}
}
Loading