Add means to prevent registration on the testing site.
This commit is contained in:
parent
fdbf4efe85
commit
ccb1d5536b
2 changed files with 31 additions and 16 deletions
|
@ -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'])) {
|
||||
|
|
|
@ -4,11 +4,16 @@
|
|||
|
||||
{% block banner_content %}
|
||||
<h1 style="align-self: center; text-align: left; flex-grow: 1; padding-left: 2em">
|
||||
{% if not prevent_registration %}
|
||||
Welcome, thanks for dropping by!
|
||||
{% else %}
|
||||
Stop!
|
||||
{% endif %}
|
||||
</h1>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if not prevent_registration %}
|
||||
<div class="platform form" id="auth-form">
|
||||
<div>
|
||||
<input class="form__text" type="text" name="username" placeholder="Username">
|
||||
|
@ -24,4 +29,9 @@
|
|||
</div>
|
||||
</div>
|
||||
{{ 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>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
Loading…
Add table
Reference in a new issue