Merge pull request #2176 from billmn/patch-1

Fixed redirects with “cachet_redirect” helper
This commit is contained in:
James Brooks
2016-10-13 08:56:23 +01:00
committed by GitHub
13 changed files with 83 additions and 62 deletions
+4 -4
View File
@@ -58,7 +58,7 @@ class AuthController extends Controller
if (Auth::user()->hasTwoFactor) { if (Auth::user()->hasTwoFactor) {
Session::put('2fa_id', Auth::user()->id); Session::put('2fa_id', Auth::user()->id);
return cachet_route('auth.two-factor'); return cachet_redirect('auth.two-factor');
} }
Auth::attempt($loginData, $rememberUser); Auth::attempt($loginData, $rememberUser);
@@ -68,7 +68,7 @@ class AuthController extends Controller
return Redirect::intended(cachet_route('dashboard')); return Redirect::intended(cachet_route('dashboard'));
} }
return cachet_route('auth.login') return cachet_redirect('auth.login')
->withInput(Binput::except('password')) ->withInput(Binput::except('password'))
->withError(trans('forms.login.invalid')); ->withError(trans('forms.login.invalid'));
} }
@@ -113,11 +113,11 @@ class AuthController extends Controller
// Failed login, log back out. // Failed login, log back out.
Auth::logout(); 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'));
} }
/** /**
@@ -137,7 +137,7 @@ class ComponentController extends Controller
$componentData['enabled'] $componentData['enabled']
)); ));
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('dashboard.components.edit', [$component->id]) return cachet_redirect('dashboard.components.edit', [$component->id])
->withInput(Binput::all()) ->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.edit.failure'))) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.edit.failure')))
->withErrors($e->getMessageBag()); ->withErrors($e->getMessageBag());
@@ -153,7 +153,7 @@ class ComponentController extends Controller
$component->tags()->sync($componentTags); $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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.edit.success')));
} }
@@ -190,7 +190,7 @@ class ComponentController extends Controller
$componentData['enabled'] $componentData['enabled']
)); ));
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('dashboard.components.create') return cachet_redirect('dashboard.components.create')
->withInput(Binput::all()) ->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.add.failure'))) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.add.failure')))
->withErrors($e->getMessageBag()); ->withErrors($e->getMessageBag());
@@ -206,7 +206,7 @@ class ComponentController extends Controller
$component->tags()->sync($componentTags); $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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.add.success')));
} }
@@ -221,7 +221,7 @@ class ComponentController extends Controller
{ {
dispatch(new RemoveComponentCommand($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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.delete.success')));
} }
@@ -236,7 +236,7 @@ class ComponentController extends Controller
{ {
dispatch(new RemoveComponentGroupCommand($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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.delete.success')));
} }
@@ -280,13 +280,13 @@ class ComponentController extends Controller
Binput::get('visible') Binput::get('visible')
)); ));
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('dashboard.components.groups.create') return cachet_redirect('dashboard.components.groups.create')
->withInput(Binput::all()) ->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.groups.add.failure'))) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.groups.add.failure')))
->withErrors($e->getMessageBag()); ->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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.groups.add.success')));
} }
@@ -308,13 +308,13 @@ class ComponentController extends Controller
Binput::get('visible') Binput::get('visible')
)); ));
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('dashboard.components.groups.edit', [$group->id]) return cachet_redirect('dashboard.components.groups.edit', [$group->id])
->withInput(Binput::all()) ->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.groups.edit.failure'))) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.groups.edit.failure')))
->withErrors($e->getMessageBag()); ->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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.groups.edit.success')));
} }
} }
@@ -82,7 +82,7 @@ class DashboardController extends Controller
*/ */
public function redirectAdmin() public function redirectAdmin()
{ {
return cachet_route('dashboard'); return cachet_redirect('dashboard');
} }
/** /**
@@ -138,13 +138,13 @@ class IncidentController extends Controller
null null
)); ));
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('dashboard.incidents.create') return cachet_redirect('dashboard.incidents.create')
->withInput(Binput::all()) ->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.add.failure'))) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.add.failure')))
->withErrors($e->getMessageBag()); ->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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.add.success')));
} }
@@ -184,7 +184,7 @@ class IncidentController extends Controller
{ {
$template->delete(); $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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.templates.delete.success')));
} }
@@ -198,13 +198,13 @@ class IncidentController extends Controller
try { try {
IncidentTemplate::create(Binput::get('template')); IncidentTemplate::create(Binput::get('template'));
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('dashboard.templates.create') return cachet_redirect('dashboard.templates.create')
->withInput(Binput::all()) ->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.add.failure'))) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.add.failure')))
->withErrors($e->getMessageBag()); ->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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.templates.add.success')));
} }
@@ -219,7 +219,7 @@ class IncidentController extends Controller
{ {
dispatch(new RemoveIncidentCommand($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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.delete.success')));
} }
@@ -264,7 +264,7 @@ class IncidentController extends Controller
null null
)); ));
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('dashboard.incidents.edit', ['id' => $incident->id]) return cachet_redirect('dashboard.incidents.edit', ['id' => $incident->id])
->withInput(Binput::all()) ->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure'))) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure')))
->withErrors($e->getMessageBag()); ->withErrors($e->getMessageBag());
@@ -274,7 +274,7 @@ class IncidentController extends Controller
$incident->component->update(['status' => Binput::get('component_status')]); $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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.edit.success')));
} }
@@ -290,12 +290,12 @@ class IncidentController extends Controller
try { try {
$template->update(Binput::get('template')); $template->update(Binput::get('template'));
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('dashboard.templates.edit', ['id' => $template->id]) return cachet_redirect('dashboard.templates.edit', ['id' => $template->id])
->withUpdatedTemplate($template) ->withUpdatedTemplate($template)
->withTemplateErrors($e->getMessageBag()->getErrors()); ->withTemplateErrors($e->getMessageBag()->getErrors());
} }
return cachet_route('dashboard.templates.edit', ['id' => $template->id]) return cachet_redirect('dashboard.templates.edit', ['id' => $template->id])
->withUpdatedTemplate($template); ->withUpdatedTemplate($template);
} }
@@ -328,13 +328,13 @@ class IncidentController extends Controller
$this->auth->user() $this->auth->user()
)); ));
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('dashboard.incidents.update', ['id' => $incident->id]) return cachet_redirect('dashboard.incidents.update', ['id' => $incident->id])
->withInput(Binput::all()) ->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure'))) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure')))
->withErrors($e->getMessageBag()); ->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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.delete.success')));
} }
} }
@@ -82,13 +82,13 @@ class MetricController extends Controller
$metricData['threshold'] $metricData['threshold']
)); ));
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('dashboard.metrics.create') return cachet_redirect('dashboard.metrics.create')
->withInput(Binput::all()) ->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.metrics.add.failure'))) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.metrics.add.failure')))
->withErrors($e->getMessageBag()); ->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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.add.success')));
} }
@@ -114,7 +114,7 @@ class MetricController extends Controller
{ {
dispatch(new RemoveMetricCommand($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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.delete.success')));
} }
@@ -155,13 +155,13 @@ class MetricController extends Controller
Binput::get('threshold', null, false) Binput::get('threshold', null, false)
)); ));
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('dashboard.metrics.edit', [$metric->id]) return cachet_redirect('dashboard.metrics.edit', [$metric->id])
->withInput(Binput::all()) ->withInput(Binput::all())
->withTitle(sprintf('<strong>%s</strong>', trans('dashboard.notifications.whoops'))) ->withTitle(sprintf('<strong>%s</strong>', trans('dashboard.notifications.whoops')))
->withErrors($e->getMessageBag()); ->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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.edit.success')));
} }
} }
@@ -100,13 +100,13 @@ class ScheduleController extends Controller
Binput::get('scheduled_at') Binput::get('scheduled_at')
)); ));
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('dashboard.schedule.create') return cachet_redirect('dashboard.schedule.create')
->withInput(Binput::all()) ->withInput(Binput::all())
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.add.failure'))) ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.add.failure')))
->withErrors($e->getMessageBag()); ->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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.add.success')));
} }
@@ -145,7 +145,7 @@ class ScheduleController extends Controller
$messageBag = new MessageBag(); $messageBag = new MessageBag();
$messageBag->add('scheduled_at', trans('validation.date', ['attribute' => 'scheduled time you supplied'])); $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; $scheduleData['scheduled_at'] = $scheduledAt;
@@ -155,13 +155,13 @@ class ScheduleController extends Controller
try { try {
$schedule->update($scheduleData); $schedule->update($scheduleData);
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('dashboard.schedule.edit', [$schedule->id]) return cachet_redirect('dashboard.schedule.edit', [$schedule->id])
->withInput(Binput::all()) ->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.edit.failure'))) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.edit.failure')))
->withErrors($e->getMessageBag()); ->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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.edit.success')));
} }
@@ -176,7 +176,7 @@ class ScheduleController extends Controller
{ {
$schedule->delete(); $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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.delete.success')));
} }
} }
@@ -61,13 +61,13 @@ class SubscriberController extends Controller
dispatch(new SubscribeSubscriberCommand($subscriber, $verified)); dispatch(new SubscribeSubscriberCommand($subscriber, $verified));
} }
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('dashboard.subscribers.create') return cachet_redirect('dashboard.subscribers.create')
->withInput(Binput::all()) ->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.subscribers.add.failure'))) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.subscribers.add.failure')))
->withErrors($e->getMessageBag()); ->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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.subscribers.add.success')));
} }
@@ -84,6 +84,6 @@ class SubscriberController extends Controller
{ {
dispatch(new UnsubscribeSubscriberCommand($subscriber)); dispatch(new UnsubscribeSubscriberCommand($subscriber));
return cachet_route('dashboard.subscribers'); return cachet_redirect('dashboard.subscribers');
} }
} }
@@ -87,13 +87,13 @@ class TeamController extends Controller
Binput::get('level') Binput::get('level')
)); ));
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('dashboard.team.create') return cachet_redirect('dashboard.team.create')
->withInput(Binput::except('password')) ->withInput(Binput::except('password'))
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.add.failure'))) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.add.failure')))
->withErrors($e->getMessageBag()); ->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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.add.success')));
} }
@@ -111,13 +111,13 @@ class TeamController extends Controller
try { try {
$user->update($userData); $user->update($userData);
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('dashboard.team.edit', [$user->id]) return cachet_redirect('dashboard.team.edit', [$user->id])
->withInput($userData) ->withInput($userData)
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure'))) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure')))
->withErrors($e->getMessageBag()); ->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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.edit.success')));
} }
@@ -133,13 +133,13 @@ class TeamController extends Controller
array_unique(array_filter((array) Binput::get('emails'))) array_unique(array_filter((array) Binput::get('emails')))
)); ));
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('dashboard.team.invite') return cachet_redirect('dashboard.team.invite')
->withInput(Binput::except('password')) ->withInput(Binput::except('password'))
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.invite.failure'))) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.invite.failure')))
->withErrors($e->getMessageBag()); ->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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.invite.success')));
} }
@@ -154,7 +154,7 @@ class TeamController extends Controller
{ {
dispatch(new RemoveUserCommand($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'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.delete.success')));
} }
} }
@@ -58,13 +58,13 @@ class UserController extends Controller
try { try {
Auth::user()->update($userData); Auth::user()->update($userData);
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('dashboard.user') return cachet_redirect('dashboard.user')
->withInput($userData) ->withInput($userData)
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure'))) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure')))
->withErrors($e->getMessageBag()); ->withErrors($e->getMessageBag());
} }
return cachet_route('dashboard.user') return cachet_redirect('dashboard.user')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.edit.success'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.edit.success')));
} }
@@ -82,6 +82,6 @@ class UserController extends Controller
event(new UserRegeneratedApiTokenEvent($user)); event(new UserRegeneratedApiTokenEvent($user));
return cachet_route('dashboard.user'); return cachet_redirect('dashboard.user');
} }
} }
+2 -2
View File
@@ -267,14 +267,14 @@ class SetupController extends Controller
return Response::json(['status' => 1]); return Response::json(['status' => 1]);
} }
return cachet_route('dashboard'); return cachet_redirect('dashboard');
} }
if (Request::ajax()) { if (Request::ajax()) {
return Response::json(['errors' => $v->getMessageBag()], 400); return Response::json(['errors' => $v->getMessageBag()], 400);
} }
return cachet_route('setup')->withInput()->withErrors($v->getMessageBag()); return cachet_redirect('setup')->withInput()->withErrors($v->getMessageBag());
} }
/** /**
+2 -2
View File
@@ -76,7 +76,7 @@ class SignupController extends Controller
User::LEVEL_USER User::LEVEL_USER
)); ));
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('signup.invite', [$invite->code]) return cachet_redirect('signup.invite', [$invite->code])
->withInput(Binput::except('password')) ->withInput(Binput::except('password'))
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.signup.failure'))) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.signup.failure')))
->withErrors($e->getMessageBag()); ->withErrors($e->getMessageBag());
@@ -84,7 +84,7 @@ class SignupController extends Controller
dispatch(new ClaimInviteCommand($invite)); dispatch(new ClaimInviteCommand($invite));
return cachet_route('status-page') return cachet_redirect('status-page')
->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.signup.success'))); ->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.signup.success')));
} }
} }
+7 -7
View File
@@ -62,17 +62,17 @@ class SubscribeController extends Controller
try { try {
$subscription = dispatch(new SubscribeSubscriberCommand($email, $verified)); $subscription = dispatch(new SubscribeSubscriberCommand($email, $verified));
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('status-page') return cachet_redirect('status-page')
->withInput(Binput::all()) ->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure'))) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))
->withErrors($e->getMessageBag()); ->withErrors($e->getMessageBag());
} }
if ($subscription->is_verified) { if ($subscription->is_verified) {
return cachet_route('status-page')->withSuccess(trans('cachet.subscriber.email.already-subscribed', ['email' => $email])); return cachet_redirect('status-page')->withSuccess(trans('cachet.subscriber.email.already-subscribed', ['email' => $email]));
} }
return cachet_route('subscribe.manage', $subscription->verify_code) return cachet_redirect('subscribe.manage', $subscription->verify_code)
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed')));
} }
@@ -99,7 +99,7 @@ class SubscribeController extends Controller
dispatch(new VerifySubscriberCommand($subscriber)); dispatch(new VerifySubscriberCommand($subscriber));
} }
return cachet_route('status-page') return cachet_redirect('status-page')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.verified'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.verified')));
} }
@@ -129,7 +129,7 @@ class SubscribeController extends Controller
dispatch(new UnsubscribeSubscriberCommand($subscriber, $subscription)); dispatch(new UnsubscribeSubscriberCommand($subscriber, $subscription));
} }
return cachet_route('status-page') return cachet_redirect('status-page')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.unsubscribed'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.unsubscribed')));
} }
@@ -184,13 +184,13 @@ class SubscribeController extends Controller
try { try {
dispatch(new UpdateSubscriberSubscriptionCommand($subscriber, Binput::get('subscriptions'))); dispatch(new UpdateSubscriberSubscriptionCommand($subscriber, Binput::get('subscriptions')));
} catch (ValidationException $e) { } catch (ValidationException $e) {
return cachet_route('subscribe.manage', $subscriber->verify_code) return cachet_redirect('subscribe.manage', $subscriber->verify_code)
->withInput(Binput::all()) ->withInput(Binput::all())
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure'))) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))
->withErrors($e->getMessageBag()); ->withErrors($e->getMessageBag());
} }
return cachet_route('subscribe.manage', $subscriber->verify_code) return cachet_redirect('subscribe.manage', $subscriber->verify_code)
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed'))); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed')));
} }
} }
+21
View File
@@ -156,3 +156,24 @@ if (!function_exists('cachet_route')) {
return app('url')->route("{$domain}::{$method}:{$name}", $parameters, true); return app('url')->route("{$domain}::{$method}:{$name}", $parameters, true);
} }
} }
if (!function_exists('cachet_redirect')) {
/**
* Create a new redirect response to a named route, which resides in a given domain.
*
* @param string $name
* @param array $parameters
* @param int $status
* @param array $headers
* @param string $method
* @param string $domain
*
* @return \Illuminate\Http\RedirectResponse
*/
function cachet_redirect($name, $parameters = [], $status = 302, $headers = [], $method = 'get', $domain = 'core')
{
$url = cachet_route($name, $parameters, $method, $domain);
return app('redirect')->to($url, $status, $headers);
}
}