Code cleanup + Settings
This commit is contained in:
@@ -519,17 +519,36 @@ If the invitation was not intended, you can simply ignore this email.<br><br><a
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
private function checkSettings() {
|
||||
$req = new \Api\Settings\Get($this->user);
|
||||
$this->success = $req->execute(array("key" => "user_registration_enabled"));
|
||||
$this->lastError = $req->getLastError();
|
||||
|
||||
if ($this->success) {
|
||||
return ($req->getResult()["user_registration_enabled"] ?? "0") === "1";
|
||||
}
|
||||
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function execute($values = array()) {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->user->isLoggedIn()) {
|
||||
$this->lastError = L('You are already logged in');
|
||||
$this->success = false;
|
||||
return $this->createError(L('You are already logged in'));
|
||||
}
|
||||
|
||||
$registrationAllowed = $this->checkSettings();
|
||||
if (!$this->success) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$registrationAllowed) {
|
||||
return $this->createError("User Registration is not enabled.");
|
||||
}
|
||||
|
||||
$username = $this->getParam("username");
|
||||
$email = $this->getParam('email');
|
||||
if (!$this->userExists($username, $email)) {
|
||||
|
||||
Reference in New Issue
Block a user