diff --git a/compass/.env.example b/compass/.env.example index c27d0ab..6ecaa00 100644 --- a/compass/.env.example +++ b/compass/.env.example @@ -41,6 +41,11 @@ CACHE_DRIVER=redis # if it supports the IndieAuth protocol https://indieweb.org/indieauth-for-login DEFAULT_AUTH_ENDPOINT=https://indieauth.com/auth +# If this is true, then anyone can create accounts. If false, then only existing +# users in the users table will be able to log in. You can add your own domain name +# to the users table to allow yourself to log in the first time. +ALLOW_NEW_USERS=false + APP_ENV=local APP_DEBUG=false diff --git a/compass/app/Http/Controllers/IndieAuth.php b/compass/app/Http/Controllers/IndieAuth.php index 30ee6d9..58536b8 100644 --- a/compass/app/Http/Controllers/IndieAuth.php +++ b/compass/app/Http/Controllers/IndieAuth.php @@ -19,6 +19,13 @@ class IndieAuth extends BaseController return view('auth/error', ['error' => 'Invalid URL']); } + if(!env('ALLOW_NEW_USERS')) { + $user = DB::table('users')->where('url', $me)->first(); + if(!$user) { + return view('auth/error', ['error' => 'User Not Registered']); + } + } + $state = \IndieAuth\Client::generateStateParameter(); if(preg_match('/https?:\/\/github\.com\/[^ \/]+/', $me)) { diff --git a/compass/resources/views/auth/error.blade.php b/compass/resources/views/auth/error.blade.php index 956f777..d70999f 100644 --- a/compass/resources/views/auth/error.blade.php +++ b/compass/resources/views/auth/error.blade.php @@ -2,8 +2,9 @@ @section('content') -

Something went wrong

+
+

Something went wrong

+

{{ $error }}

+
-{{ $error }} - -@endsection \ No newline at end of file +@endsection