diff --git a/app/Dashboard.php b/app/Dashboard.php index 4f69c65..544225b 100644 --- a/app/Dashboard.php +++ b/app/Dashboard.php @@ -84,4 +84,15 @@ class Dashboard return null; } } + + /** + * Checks the registration status against the REGISTRATION variable in .env + * + * @return boolean + */ + public static function canRegister() + { + $registration_status = env('REGISTRATION', false); + return $registration_status === true || $registration_status === \Request::ip(); + } } diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 431d682..0c6b5c0 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -1,6 +1,7 @@ $data['name'], 'email' => $data['email'], 'password' => Hash::make($data['password']), 'api_token' => str_random(60) ]); + } else { + abort(404); } } @@ -78,7 +81,7 @@ class RegisterController extends Controller { */ public function showRegistrationForm() { - if (env('REGISTRATION', false)) { + if (Dashboard::canRegister()) { return view('auth.register'); } else { header('Location: /login'); diff --git a/resources/views/dashboard/sections/nav.blade.php b/resources/views/dashboard/sections/nav.blade.php index 4d3337f..4b239a4 100644 --- a/resources/views/dashboard/sections/nav.blade.php +++ b/resources/views/dashboard/sections/nav.blade.php @@ -16,7 +16,7 @@ @if (Auth::guest()) - @if(env('REGISTRATION', false)) + @if(App\Dashboard::canRegister()) @endif @else