Add means to prevent registration on the testing site.

This commit is contained in:
flash 2018-03-13 23:04:01 +01:00
parent fdbf4efe85
commit ccb1d5536b
2 changed files with 31 additions and 16 deletions

View file

@ -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 '<meta http-equiv="refresh" content="0; url=/">';
}
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'])) {

View file

@ -4,24 +4,34 @@
{% block banner_content %}
<h1 style="align-self: center; text-align: left; flex-grow: 1; padding-left: 2em">
Welcome, thanks for dropping by!
{% if not prevent_registration %}
Welcome, thanks for dropping by!
{% else %}
Stop!
{% endif %}
</h1>
{% endblock %}
{% block content %}
<div class="platform form" id="auth-form">
<div>
<input class="form__text" type="text" name="username" placeholder="Username">
{% if not prevent_registration %}
<div class="platform form" id="auth-form">
<div>
<input class="form__text" type="text" name="username" placeholder="Username">
</div>
<div>
<input class="form__text" type="password" name="password" placeholder="Password">
</div>
<div>
<input class="form__text" type="text" name="email" placeholder="E-mail">
</div>
<div>
<button class="button">Create your account!</button>
</div>
</div>
<div>
<input class="form__text" type="password" name="password" placeholder="Password">
{{ parent() }}
{% else %}
<div class="platform">
<p>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.</p>
</div>
<div>
<input class="form__text" type="text" name="email" placeholder="E-mail">
</div>
<div>
<button class="button">Create your account!</button>
</div>
</div>
{{ parent() }}
{% endif %}
{% endblock %}