Compare commits

..

1 Commits

Author SHA1 Message Date
Dan Brown
c49454da28 Added crude example of captcha usage 2019-09-09 21:19:08 +01:00
8 changed files with 27 additions and 7282 deletions

6
.gitignore vendored
View File

@@ -5,10 +5,10 @@ Homestead.yaml
.idea
npm-debug.log
yarn-error.log
/public/dist/*.map
/public/dist
/public/plugins
/public/css/*.map
/public/js/*.map
/public/css
/public/js
/public/bower
/public/build/
/storage/images

View File

@@ -13,6 +13,7 @@ use BookStack\Exceptions\SocialSignInException;
use BookStack\Exceptions\UserRegistrationException;
use BookStack\Http\Controllers\Controller;
use Exception;
use GuzzleHttp\Client;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
@@ -115,6 +116,20 @@ class RegisterController extends Controller
$this->checkRegistrationAllowed();
$this->validator($request->all())->validate();
$captcha = $request->get('g-recaptcha-response');
$resp = (new Client())->post('https://www.google.com/recaptcha/api/siteverify', [
'form_params' => [
'response' => $captcha,
'secret' => '%%secret_key%%',
]
]);
$respBody = json_decode($resp->getBody());
if (!$respBody->success) {
return redirect()->back()->withInput()->withErrors([
'g-recaptcha-response' => 'Did not pass captcha',
]);
}
$userData = $request->all();
return $this->registerUser($userData);
}

27
public/dist/app.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -1,36 +0,0 @@
:root {
--color-primary: #206ea7;
--color-primary-light: rgba(32,110,167,0.15);
--color-page: #206ea7;
--color-page-draft: #7e50b1;
--color-chapter: #af4d0d;
--color-book: #077b70;
--color-bookshelf: #a94747; }
header {
display: none; }
html, body {
font-size: 12px;
background-color: #FFF; }
.page-content {
margin: 0 auto; }
.print-hidden {
display: none !important; }
.tri-layout-container {
grid-template-columns: 1fr;
grid-template-areas: "b";
margin-left: 0;
margin-right: 0;
display: block; }
.card {
box-shadow: none; }
.content-wrap.card {
padding-left: 0;
padding-right: 0; }

4430
public/dist/styles.css vendored

File diff suppressed because it is too large Load Diff

View File

@@ -26,6 +26,14 @@
@include('form.password', ['name' => 'password', 'placeholder' => trans('auth.password_hint')])
</div>
<div class="form-group">
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<div class="g-recaptcha" data-sitekey="%%site_key%%"></div>
@if($errors->has('g-recaptcha-response'))
<div class="text-neg text-small">{{ $errors->first('g-recaptcha-response') }}</div>
@endif
</div>
<div class="grid half collapse-xs gap-xl v-center mt-m">
<div class="text-small">
<a href="{{ url('/login') }}">{{ trans('auth.already_have_account') }}</a>

View File

@@ -1 +1 @@
v0.27.4
v0.27-dev