fix: user registration when it's disabled
This commit is contained in:
parent
f37ac929cc
commit
3ef5f24d05
2 changed files with 23 additions and 33 deletions
|
@ -507,7 +507,7 @@ class Page
|
|||
'icon' => 'sign out alternate',
|
||||
];
|
||||
} else {
|
||||
$pages[$login] = [
|
||||
$pages[$login] = [
|
||||
'text' => __('Login'),
|
||||
'alignment' => 'right',
|
||||
'items' => [
|
||||
|
@ -518,17 +518,22 @@ class Page
|
|||
],
|
||||
],
|
||||
];
|
||||
$pages[$register] = [
|
||||
'text' => __('Register'),
|
||||
'alignment' => 'right',
|
||||
'items' => [
|
||||
[
|
||||
'text' => __('Register'),
|
||||
'url' => Page::PAGE_REGISTER,
|
||||
'icon' => 'user plus alternate',
|
||||
|
||||
$registrationDisabled = defined('DISABLE_USER_REGISTRATION') && true === DISABLE_USER_REGISTRATION;
|
||||
|
||||
if (!$registrationDisabled) {
|
||||
$pages[$register] = [
|
||||
'text' => __('Register'),
|
||||
'alignment' => 'right',
|
||||
'items' => [
|
||||
[
|
||||
'text' => __('Register'),
|
||||
'url' => Page::PAGE_REGISTER,
|
||||
'icon' => 'user plus alternate',
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (100 === $user->getPower()) {
|
||||
|
|
|
@ -8,14 +8,15 @@
|
|||
|
||||
namespace wishthis;
|
||||
|
||||
$passwordReset = isset($_GET['password-reset'], $_GET['token']);
|
||||
$passwordReset = isset($_GET['password-reset'], $_GET['token']);
|
||||
$registrationDisabled = defined('DISABLE_USER_REGISTRATION') && true === DISABLE_USER_REGISTRATION;
|
||||
|
||||
$pageTitle = $passwordReset ? __('Reset password') : __('Register');
|
||||
$buttonSubmit = $passwordReset ? __('Reset') : __('Register');
|
||||
|
||||
$page = new Page(__FILE__, $pageTitle);
|
||||
|
||||
if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
|
||||
if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet']) && !$registrationDisabled) {
|
||||
$users = $database
|
||||
->query(
|
||||
'SELECT *
|
||||
|
@ -115,14 +116,6 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
|
|||
$locale_user = $locale_browser;
|
||||
}
|
||||
|
||||
if (defined('DISABLE_USER_REGISTRATION') && true === DISABLE_USER_REGISTRATION) {
|
||||
\http_response_code(403);
|
||||
|
||||
die(__('The owner of this site has disabled user registrations.'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register
|
||||
*/
|
||||
|
@ -221,17 +214,11 @@ $page->navigation();
|
|||
|
||||
<?= $page->messages() ?>
|
||||
|
||||
<?php
|
||||
if (defined('DISABLE_USER_REGISTRATION') && true === DISABLE_USER_REGISTRATION) {
|
||||
?>
|
||||
<?php if ($registrationDisabled) { ?>
|
||||
<div class="ui segment">
|
||||
<h2 class="ui header"><?= __('Registration disabled') ?></h2>
|
||||
|
||||
<p><?= __('The owner of this site has disabled user registrations.') ?></p>
|
||||
<p>The owner of this instance has disabled user registration.</p>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<?php } else { ?>
|
||||
<div class="ui segment">
|
||||
<form class="ui form" method="POST">
|
||||
<div class="ui divided relaxed stackable two column grid">
|
||||
|
@ -321,9 +308,7 @@ $page->navigation();
|
|||
?>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
|
Loading…
Reference in a new issue