From e503a8da85491c906347a40d6c3603e83c85cb65 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 29 Dec 2021 00:38:08 -0700 Subject: [PATCH] Update RegisterController --- .../Controllers/Auth/RegisterController.php | 17 +++++++++++++++++ resources/views/auth/register.blade.php | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 9a41f2e0..fe9aa7fd 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -44,6 +44,13 @@ class RegisterController extends Controller $this->middleware('guest'); } + public function getRegisterToken() + { + return \Cache::remember('pf:register:rt', 900, function() { + return str_random(40); + }); + } + /** * Get a validator for an incoming registration request. * @@ -110,8 +117,18 @@ class RegisterController extends Controller }, ]; + $rt = [ + 'required', + function ($attribute, $value, $fail) { + if($value !== $this->getRegisterToken()) { + return $fail('Something went wrong'); + } + } + ]; + $rules = [ 'agecheck' => 'required|accepted', + 'rt' => $rt, 'name' => 'nullable|string|max:'.config('pixelfed.max_name_length'), 'username' => $usernameRules, 'email' => $emailRules, diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index f68afb61..5f3b6e50 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -10,7 +10,7 @@
@csrf - +