From ccb1d5536b79872893549a374be804074449754d Mon Sep 17 00:00:00 2001 From: flashwave Date: Tue, 13 Mar 2018 23:04:01 +0100 Subject: [PATCH] Add means to prevent registration on the testing site. --- src/Controllers/AuthController.php | 9 +++++-- views/nova/auth/register.twig | 38 +++++++++++++++++++----------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/Controllers/AuthController.php b/src/Controllers/AuthController.php index befda5d8..b17f5e0b 100644 --- a/src/Controllers/AuthController.php +++ b/src/Controllers/AuthController.php @@ -84,14 +84,19 @@ class AuthController extends Controller public function register() { $app = Application::getInstance(); + $prevent_registration = $app->config->get('Auth', 'prevent_registration', 'bool', false); if ($app->getSession() !== null) { return ''; } if ($_SERVER['REQUEST_METHOD'] === 'GET') { - $twig = $app->templating; - return $twig->render('auth.register'); + $app->templating->var('prevent_registration', $prevent_registration); + return $app->templating->render('auth.register'); + } + + if ($prevent_registration) { + return ['error' => 'Registration is not allowed on this instance.']; } if (!isset($_POST['username'], $_POST['password'], $_POST['email'])) { diff --git a/views/nova/auth/register.twig b/views/nova/auth/register.twig index 9325de30..b69f61ba 100644 --- a/views/nova/auth/register.twig +++ b/views/nova/auth/register.twig @@ -4,24 +4,34 @@ {% block banner_content %}

- Welcome, thanks for dropping by! + {% if not prevent_registration %} + Welcome, thanks for dropping by! + {% else %} + Stop! + {% endif %}

{% endblock %} {% block content %} -
-
- + {% if not prevent_registration %} +
+
+ +
+
+ +
+
+ +
+
+ +
-
- + {{ parent() }} + {% else %} +
+

You're currently using the site via the public testing end, if you want to create an account please do so from the main website.

-
- -
-
- -
-
- {{ parent() }} + {% endif %} {% endblock %}