Skip to content

Commit b5383c2

Browse files
authored
Merge pull request #2176 from billmn/patch-1
Fixed redirects with “cachet_redirect” helper
2 parents 2742ea0 + 411c06e commit b5383c2

13 files changed

+83
-62
lines changed

app/Http/Controllers/AuthController.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function postLogin()
5858
if (Auth::user()->hasTwoFactor) {
5959
Session::put('2fa_id', Auth::user()->id);
6060

61-
return cachet_route('auth.two-factor');
61+
return cachet_redirect('auth.two-factor');
6262
}
6363

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

71-
return cachet_route('auth.login')
71+
return cachet_redirect('auth.login')
7272
->withInput(Binput::except('password'))
7373
->withError(trans('forms.login.invalid'));
7474
}
@@ -113,11 +113,11 @@ public function postTwoFactor()
113113
// Failed login, log back out.
114114
Auth::logout();
115115

116-
return cachet_route('auth.login')->withError(trans('forms.login.invalid-token'));
116+
return cachet_redirect('auth.login')->withError(trans('forms.login.invalid-token'));
117117
}
118118
}
119119

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

123123
/**

app/Http/Controllers/Dashboard/ComponentController.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public function updateComponentAction(Component $component)
137137
$componentData['enabled']
138138
));
139139
} catch (ValidationException $e) {
140-
return cachet_route('dashboard.components.edit', [$component->id])
140+
return cachet_redirect('dashboard.components.edit', [$component->id])
141141
->withInput(Binput::all())
142142
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.edit.failure')))
143143
->withErrors($e->getMessageBag());
@@ -153,7 +153,7 @@ public function updateComponentAction(Component $component)
153153

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

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

@@ -190,7 +190,7 @@ public function createComponentAction()
190190
$componentData['enabled']
191191
));
192192
} catch (ValidationException $e) {
193-
return cachet_route('dashboard.components.create')
193+
return cachet_redirect('dashboard.components.create')
194194
->withInput(Binput::all())
195195
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.add.failure')))
196196
->withErrors($e->getMessageBag());
@@ -206,7 +206,7 @@ public function createComponentAction()
206206

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

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

@@ -221,7 +221,7 @@ public function deleteComponentAction(Component $component)
221221
{
222222
dispatch(new RemoveComponentCommand($component));
223223

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

@@ -236,7 +236,7 @@ public function deleteComponentGroupAction(ComponentGroup $group)
236236
{
237237
dispatch(new RemoveComponentGroupCommand($group));
238238

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

@@ -280,13 +280,13 @@ public function postAddComponentGroup()
280280
Binput::get('visible')
281281
));
282282
} catch (ValidationException $e) {
283-
return cachet_route('dashboard.components.groups.create')
283+
return cachet_redirect('dashboard.components.groups.create')
284284
->withInput(Binput::all())
285285
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.groups.add.failure')))
286286
->withErrors($e->getMessageBag());
287287
}
288288

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

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

317-
return cachet_route('dashboard.components.groups.edit', [$group->id])
317+
return cachet_redirect('dashboard.components.groups.edit', [$group->id])
318318
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.groups.edit.success')));
319319
}
320320
}

app/Http/Controllers/Dashboard/DashboardController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function __construct(Feed $feed, Guard $guard)
8282
*/
8383
public function redirectAdmin()
8484
{
85-
return cachet_route('dashboard');
85+
return cachet_redirect('dashboard');
8686
}
8787

8888
/**

app/Http/Controllers/Dashboard/IncidentController.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,13 @@ public function createIncidentAction()
138138
null
139139
));
140140
} catch (ValidationException $e) {
141-
return cachet_route('dashboard.incidents.create')
141+
return cachet_redirect('dashboard.incidents.create')
142142
->withInput(Binput::all())
143143
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.add.failure')))
144144
->withErrors($e->getMessageBag());
145145
}
146146

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

@@ -184,7 +184,7 @@ public function deleteTemplateAction(IncidentTemplate $template)
184184
{
185185
$template->delete();
186186

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

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

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

@@ -219,7 +219,7 @@ public function deleteIncidentAction(Incident $incident)
219219
{
220220
dispatch(new RemoveIncidentCommand($incident));
221221

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

@@ -264,7 +264,7 @@ public function editIncidentAction(Incident $incident)
264264
null
265265
));
266266
} catch (ValidationException $e) {
267-
return cachet_route('dashboard.incidents.edit', ['id' => $incident->id])
267+
return cachet_redirect('dashboard.incidents.edit', ['id' => $incident->id])
268268
->withInput(Binput::all())
269269
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure')))
270270
->withErrors($e->getMessageBag());
@@ -274,7 +274,7 @@ public function editIncidentAction(Incident $incident)
274274
$incident->component->update(['status' => Binput::get('component_status')]);
275275
}
276276

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

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

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

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

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

app/Http/Controllers/Dashboard/MetricController.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ public function createMetricAction()
8282
$metricData['threshold']
8383
));
8484
} catch (ValidationException $e) {
85-
return cachet_route('dashboard.metrics.create')
85+
return cachet_redirect('dashboard.metrics.create')
8686
->withInput(Binput::all())
8787
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.metrics.add.failure')))
8888
->withErrors($e->getMessageBag());
8989
}
9090

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

@@ -114,7 +114,7 @@ public function deleteMetricAction(Metric $metric)
114114
{
115115
dispatch(new RemoveMetricCommand($metric));
116116

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

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

164-
return cachet_route('dashboard.metrics.edit', [$metric->id])
164+
return cachet_redirect('dashboard.metrics.edit', [$metric->id])
165165
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.edit.success')));
166166
}
167167
}

app/Http/Controllers/Dashboard/ScheduleController.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ public function addScheduleAction()
100100
Binput::get('scheduled_at')
101101
));
102102
} catch (ValidationException $e) {
103-
return cachet_route('dashboard.schedule.create')
103+
return cachet_redirect('dashboard.schedule.create')
104104
->withInput(Binput::all())
105105
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.add.failure')))
106106
->withErrors($e->getMessageBag());
107107
}
108108

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

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

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

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

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

@@ -176,7 +176,7 @@ public function deleteScheduleAction(Incident $schedule)
176176
{
177177
$schedule->delete();
178178

179-
return cachet_route('dashboard.schedule')
179+
return cachet_redirect('dashboard.schedule')
180180
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.delete.success')));
181181
}
182182
}

app/Http/Controllers/Dashboard/SubscriberController.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ public function createSubscriberAction()
6161
dispatch(new SubscribeSubscriberCommand($subscriber, $verified));
6262
}
6363
} catch (ValidationException $e) {
64-
return cachet_route('dashboard.subscribers.create')
64+
return cachet_redirect('dashboard.subscribers.create')
6565
->withInput(Binput::all())
6666
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.subscribers.add.failure')))
6767
->withErrors($e->getMessageBag());
6868
}
6969

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

@@ -84,6 +84,6 @@ public function deleteSubscriberAction(Subscriber $subscriber)
8484
{
8585
dispatch(new UnsubscribeSubscriberCommand($subscriber));
8686

87-
return cachet_route('dashboard.subscribers');
87+
return cachet_redirect('dashboard.subscribers');
8888
}
8989
}

app/Http/Controllers/Dashboard/TeamController.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ public function postAddUser()
8787
Binput::get('level')
8888
));
8989
} catch (ValidationException $e) {
90-
return cachet_route('dashboard.team.create')
90+
return cachet_redirect('dashboard.team.create')
9191
->withInput(Binput::except('password'))
9292
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.add.failure')))
9393
->withErrors($e->getMessageBag());
9494
}
9595

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

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

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

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

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

@@ -154,7 +154,7 @@ public function deleteUser(User $user)
154154
{
155155
dispatch(new RemoveUserCommand($user));
156156

157-
return cachet_route('dashboard.team')
157+
return cachet_redirect('dashboard.team')
158158
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.delete.success')));
159159
}
160160
}

0 commit comments

Comments
 (0)