Skip to content

Commit a39f7d8

Browse files
committed
cleanup invite logic
1 parent 8504558 commit a39f7d8

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

app/Http/Controllers/PageController.php

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -275,24 +275,20 @@ public function showCommunity()
275275

276276
public function showInviteForm(Request $request)
277277
{
278-
if ($request->hashid == null) {
279-
return 'invalid - 1';
280-
} else {
281-
$id = Hashids::decode($request->hashid);
282-
if (empty($id)) {
283-
return 'invalid - 2';
284-
}
285-
$applicant = Applicant::find($id[0]);
286-
if ($applicant->decision == 2) {
287-
return 'link expired - account already created';
288-
}
289-
290-
if ($applicant->decision != 1) {
291-
return 'invalid - 3';
292-
}
278+
$id = Hashids::decode($request->hashid);
279+
if (empty($id)) {
280+
return redirect()->action('PageController@index')->with('message', 'Invalid link');
281+
}
282+
$applicant = Applicant::find($id[0]);
283+
if ($applicant->decision == 2) {
284+
return redirect()->action('PageController@index')->with('message', 'Expired link');
285+
}
293286

294-
return view('invite', ['applicant' => $applicant]);
287+
if ($applicant->decision != 1) {
288+
return redirect()->action('PageController@index')->with('message', 'Invalid link');
295289
}
290+
291+
return view('invite', ['applicant' => $applicant]);
296292
}
297293

298294
public function submitInviteForm(Request $request)

resources/views/index.blade.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@
7474
<div class="container">
7575
<div class="row">
7676
<div class="col-md-8 offset-md-2">
77+
@if(session('message'))
78+
<div class="alert alert-danger">{{ session('message') }}</div>
79+
@endif
7780
<img src="img/logo.png" class="img-fluid logo">
7881
<h1 class="brand-heading">{{ env('APP_NAME') }}</h1>
7982
@if (env('APPLICATIONS_OPEN') == false)

routes/web.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
return redirect('https://www.gitbook.com/@launchpadcs');
2020
});
2121

22-
Route::get('invite/{hashid?}', 'PageController@showInviteForm');
22+
Route::get('invite/{hashid}', 'PageController@showInviteForm');
2323
Route::post('invite', 'PageController@submitInviteForm');
2424

2525
Route::group(['middleware' => ['phase:1']], function () {

0 commit comments

Comments
 (0)