開発環境向けの措置として、reCAPTCHAは任意設定とする
This commit is contained in:
parent
fcdb9d7aba
commit
2299ac3fe7
@ -36,5 +36,7 @@ PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
|
||||
# (Optional) reCAPTCHA Key
|
||||
# https://www.google.com/recaptcha
|
||||
NOCAPTCHA_SECRET=
|
||||
NOCAPTCHA_SITEKEY=
|
@ -47,12 +47,18 @@ class RegisterController extends Controller
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
$rules = [
|
||||
'name' => 'required|string|regex:/^[a-zA-Z0-9_-]+$/u|max:15|unique:users',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
'g-recaptcha-response' => 'required|captcha'
|
||||
],
|
||||
'password' => 'required|string|min:6|confirmed'
|
||||
];
|
||||
|
||||
// reCAPTCHAのキーが設定されている場合、判定を有効化
|
||||
if (!empty(config('captcha.secret'))) {
|
||||
$rules['g-recaptcha-response'] = 'required|captcha';
|
||||
}
|
||||
|
||||
return Validator::make($data, $rules,
|
||||
['name.regex' => 'ユーザー名には半角英数字とアンダーバー、ハイフンのみ使用できます。'],
|
||||
['name' => 'ユーザー名']
|
||||
);
|
||||
|
@ -3,7 +3,9 @@
|
||||
@section('title', '新規登録')
|
||||
|
||||
@push('head')
|
||||
{!! NoCaptcha::renderJs() !!}
|
||||
@if (!empty(config('captcha.secret')))
|
||||
{!! NoCaptcha::renderJs() !!}
|
||||
@endif
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
@ -57,14 +59,16 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row ml-1 mt-2 my-4">
|
||||
<div class="mx-auto">
|
||||
{!! NoCaptcha::display() !!}
|
||||
@if (!empty(config('captcha.secret')))
|
||||
<div class="form-row ml-1 mt-2 my-4">
|
||||
<div class="mx-auto">
|
||||
{!! NoCaptcha::display() !!}
|
||||
</div>
|
||||
@if ($errors->has('g-recaptcha-response'))
|
||||
<div class="invalid-feedback d-block text-center">{{ $errors->first('g-recaptcha-response') }}</div>
|
||||
@endif
|
||||
</div>
|
||||
@if ($errors->has('g-recaptcha-response'))
|
||||
<div class="invalid-feedback d-block text-center">{{ $errors->first('g-recaptcha-response') }}</div>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="text-center">
|
||||
<button class="btn btn-primary btn-lg" type="submit">登録</button>
|
||||
|
Loading…
Reference in New Issue
Block a user