diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php index 6b4338b..12a898b 100644 --- a/app/Http/Controllers/SetupController.php +++ b/app/Http/Controllers/SetupController.php @@ -22,7 +22,7 @@ class SetupController extends Controller { private static function setupAlreadyRan() { return view('error', [ - 'message' => 'Sorry, but you have already ran the setup script previously.' + 'message' => 'Sorry, but you have already completed the setup process.' ]); } @@ -112,6 +112,8 @@ class SetupController extends Controller { $st_index_redirect = $request->input('setting:index_redirect'); $st_redirect_404 = $request->input('setting:redirect_404'); $st_password_recov = $request->input('setting:password_recovery'); + $st_restrict_email_domain = $request->input('setting:restrict_email_domain'); + $st_allowed_email_domains = $request->input('setting:allowed_email_domains'); $st_base = $request->input('setting:base'); $st_auto_api_key = $request->input('setting:auto_api_key'); @@ -155,6 +157,8 @@ class SetupController extends Controller { 'ST_INDEX_REDIRECT' => $st_index_redirect, 'ST_REDIRECT_404' => $st_redirect_404, 'ST_PASSWORD_RECOV' => $st_password_recov, + 'ST_RESTRICT_EMAIL_DOMAIN' => $st_restrict_email_domain, + 'ST_ALLOWED_EMAIL_DOMAINS' => $st_allowed_email_domains, 'MAIL_ENABLED' => $mail_enabled, 'MAIL_HOST' => $mail_host, diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 4899bd8..4d4a34c 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -68,6 +68,15 @@ class UserController extends Controller { $password = $request->input('password'); $email = $request->input('email'); + if (env('SETTING_RESTRICT_EMAIL_DOMAIN')) { + $email_domain = explode('@', $email)[1]; + $permitted_email_domains = explode(',', env('SETTING_ALLOWED_EMAIL_DOMAINS')); + + if (!in_array($email_domain, $permitted_email_domains)) { + return redirect(route('signup'))->with('error', 'Sorry, your email\'s domain is not permitted to create new accounts.'); + } + } + $ip = $request->ip(); $user_exists = UserHelper::userExists($username); diff --git a/public/js/SetupCtrl.js b/public/js/SetupCtrl.js new file mode 100644 index 0000000..ed6c8a2 --- /dev/null +++ b/public/js/SetupCtrl.js @@ -0,0 +1,10 @@ +polr.controller('SetupCtrl', function($scope) { + $scope.init = function () { + $('[data-toggle="popover"]').popover({ + trigger: "hover", + placement: "right" + }); + }; + + $scope.init(); +}); diff --git a/public/js/setup.js b/public/js/setup.js deleted file mode 100644 index 924ceb2..0000000 --- a/public/js/setup.js +++ /dev/null @@ -1,6 +0,0 @@ -$(function () { - $('[data-toggle="popover"]').popover({ - trigger: "hover", - placement: "right" - }); -}); diff --git a/resources/views/env.blade.php b/resources/views/env.blade.php index 55da877..971df5d 100644 --- a/resources/views/env.blade.php +++ b/resources/views/env.blade.php @@ -77,6 +77,12 @@ SETTING_PSEUDORANDOM_ENDING={{$ST_PSEUDOR_ENDING}} # Set to true to record advanced analytics SETTING_ADV_ANALYTICS={{$ST_ADV_ANALYTICS}} +# Set to true to restrict registration to a specific email domain +SETTING_RESTRICT_EMAIL_DOMAIN={{$ST_RESTRICT_EMAIL_DOMAIN}} + +# A comma-separated list of permitted email domains +SETTING_ALLOWED_EMAIL_DOMAINS={{$ST_ALLOWED_EMAIL_DOMAINS}} + # Set each to blank to disable mail @if($MAIL_ENABLED) MAIL_DRIVER=smtp diff --git a/resources/views/layouts/minimal.blade.php b/resources/views/layouts/minimal.blade.php index 55539a0..65b93cb 100644 --- a/resources/views/layouts/minimal.blade.php +++ b/resources/views/layouts/minimal.blade.php @@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --> - + Polr @yield('title') @yield('css') diff --git a/resources/views/setup.blade.php b/resources/views/setup.blade.php index 4115a69..264811a 100644 --- a/resources/views/setup.blade.php +++ b/resources/views/setup.blade.php @@ -14,7 +14,7 @@ Setup Polr -
+
@@ -174,6 +174,21 @@ Setup +

+ Restrict Registration Email Domains: + +

+ + +

+ Permitted Email Domains: + +

+ +

Password Recovery: @@ -236,5 +251,7 @@ Setup @section('js') - + + + @endsection