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()
|
public function register()
|
||||||
{
|
{
|
||||||
$app = Application::getInstance();
|
$app = Application::getInstance();
|
||||||
|
$prevent_registration = $app->config->get('Auth', 'prevent_registration', 'bool', false);
|
||||||
|
|
||||||
if ($app->getSession() !== null) {
|
if ($app->getSession() !== null) {
|
||||||
return '<meta http-equiv="refresh" content="0; url=/">';
|
return '<meta http-equiv="refresh" content="0; url=/">';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||||
$twig = $app->templating;
|
$app->templating->var('prevent_registration', $prevent_registration);
|
||||||
return $twig->render('auth.register');
|
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'])) {
|
if (!isset($_POST['username'], $_POST['password'], $_POST['email'])) {
|
||||||
|
|
|
@ -4,24 +4,34 @@
|
||||||
|
|
||||||
{% block banner_content %}
|
{% block banner_content %}
|
||||||
<h1 style="align-self: center; text-align: left; flex-grow: 1; padding-left: 2em">
|
<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>
|
</h1>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="platform form" id="auth-form">
|
{% if not prevent_registration %}
|
||||||
<div>
|
<div class="platform form" id="auth-form">
|
||||||
<input class="form__text" type="text" name="username" placeholder="Username">
|
<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>
|
||||||
<div>
|
{{ parent() }}
|
||||||
<input class="form__text" type="password" name="password" placeholder="Password">
|
{% 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>
|
||||||
<div>
|
{% endif %}
|
||||||
<input class="form__text" type="text" name="email" placeholder="E-mail">
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<button class="button">Create your account!</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{ parent() }}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Add table
Reference in a new issue