Permalink
Browse files

Episode 89

  • Loading branch information...
JeffreyWay committed Oct 24, 2017
1 parent 6268dce commit b2193516e7655f65a9d90ca7ac24f0262a3c88d1
Showing with 302 additions and 1 deletion.
  1. +11 −0 app/Http/Controllers/ThreadsController.php
  2. +1 −0 composer.json
  3. +278 −1 composer.lock
  4. +4 −0 config/services.php
  5. +8 −0 resources/views/threads/create.blade.php
@@ -7,6 +7,7 @@
use App\Thread;
use App\Trending;
use Illuminate\Http\Request;
use Zttp\Zttp;
class ThreadsController extends Controller
{
@@ -64,6 +65,16 @@ public function store(Request $request)
'channel_id' => 'required|exists:channels,id'
]);
$response = Zttp::asFormParams()->post('https://www.google.com/recaptcha/api/siteverify', [
'secret' => config('services.recaptcha.secret'),
'response' => $request->input('g-recaptcha-response'),
'remoteip' => request()->ip()
]);
if (! $response->json()['success']) {
throw new \Exception('Recaptcha failed');
}
$thread = Thread::create([
'user_id' => auth()->id(),
'channel_id' => request('channel_id'),
@@ -7,6 +7,7 @@
"require": {
"php": ">=5.6.4",
"barryvdh/laravel-debugbar": "^2.3",
"kitetail/zttp": "^0.3.0",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"predis/predis": "^1.1"

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -35,4 +35,8 @@
'secret' => env('STRIPE_SECRET'),
],
'recaptcha' => [
'secret' => env('RECAPTCHA_SECRET')
]
];
@@ -1,5 +1,9 @@
@extends('layouts.app')
@section ('head')
<script src='https://www.google.com/recaptcha/api.js'></script>
@endsection
@section('content')
<div class="container">
<div class="row">
@@ -36,6 +40,10 @@
rows="8" required>{{ old('body') }}</textarea>
</div>
<div class="form-group">
<div class="g-recaptcha" data-sitekey="6LeXrDUUAAAAAFco7ShbMrJx0fh-ZrLxK9Amd-zP"></div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Publish</button>
</div>

0 comments on commit b219351

Please sign in to comment.