-
app/Policies/UserPolicy.php
Open in GitHubuse App\User; class UserPolicy { // public function create(?User $user) { return setting('user_can_register', true); } // }
-
app/Providers/AuthServiceProvider.php
Open in GitHubuse Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; class AuthServiceProvider extends ServiceProvider { protected $policies = [ \\ \App\User::class => \App\Policies\UserPolicy::class, \\ ]; public function boot() { $this->registerPolicies(); } }
-
app/Http/Controllers/Auth/RegisterController.php
Open in GitHubuse App\Http\Controllers\Controller; use Gate; class RegisterController extends Controller { // public function showRegistrationForm() { if (Gate::allows('create', User::class)) { return view('auth.register'); } else { abort(500, 'You cannot create an account on this server'); } } public function handleRegistrationForm(Request $request) { Gate::authorize('create', User::class); // } // }