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