register_new_matrix_user aktiviert, mangels synapse noch ungetestet
This commit is contained in:
parent
f57612c00f
commit
e6140b3b20
|
@ -38,13 +38,15 @@ class Registrator extends BaseClass {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->log->d("Validation started for token: {$_GET['token']}");
|
$this->log->n("Validation started for token: {$_GET['token']}");
|
||||||
if ($this->checkToken() === true) {
|
if ($this->checkToken() === true) {
|
||||||
if ($this->generateToken(32) === true) {
|
if ($this->generateToken(24) === true) {
|
||||||
if ($this->registerMXID($this->token) === true) {
|
if ($this->registerMXID($this->token) === true) {
|
||||||
$message = "Your temporary password is {$this->token}. Please
|
|
||||||
immediately change your password!";
|
|
||||||
if ($this->removeRequest() === true) {
|
if ($this->removeRequest() === true) {
|
||||||
|
$nick = htmlspecialchars($this->dataSet[0]['nick']);
|
||||||
|
$message = "We have successfull registered your
|
||||||
|
account. Your temporary password is:<br/>{$this->token}
|
||||||
|
<br/>Please immediately change your password!";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +73,7 @@ class Registrator extends BaseClass {
|
||||||
|
|
||||||
$count = count($this->dataSet);
|
$count = count($this->dataSet);
|
||||||
if ($count === 0) {
|
if ($count === 0) {
|
||||||
$this->log->d("Token {$_GET['token']} not found in database");
|
$this->log->e("Token {$_GET['token']} not found in database");
|
||||||
} else if ($count > 1) {
|
} else if ($count > 1) {
|
||||||
$this->log->e("Error: More than one token found");
|
$this->log->e("Error: More than one token found");
|
||||||
} else {
|
} else {
|
||||||
|
@ -84,14 +86,25 @@ class Registrator extends BaseClass {
|
||||||
private function registerMXID(string $tmp_passwd): bool {
|
private function registerMXID(string $tmp_passwd): bool {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registriert den Nutzer am Matrixserver. Dazu wird ein zufälliger
|
* Registriert den Nutzer am Matrixserver. Dazu bekommt die Funktion
|
||||||
* String erzeugt und zusammen mit dem Nick ein CLI Tool aus dem Paket
|
* einen zufällig erzeugten String als vorläufiges Passwort
|
||||||
* Paket von matrix-synapse aufgerufen.
|
* übergeben. Dieser wird zusammen mit dem Nick aus der Datenbank an
|
||||||
|
* den Befehl 'register_new_matrix_user' übergeben.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// $cmd = "register_new_matrix_user -u {$this->dataSet[0]['nick']} -p {$tmp_pass}";
|
$response = null;
|
||||||
// $response = system($cmd);
|
$output = null;
|
||||||
return true;
|
$nick = escapeshellarg($this->dataSet[0]['nick']);
|
||||||
|
$pass = escapeshellarg($tmp_passwd);
|
||||||
|
$cmd = "register_new_matrix_user -u " . $nick . " -p " . $pass;
|
||||||
|
exec($cmd, $output, $response);
|
||||||
|
if ($response === 1) {
|
||||||
|
$this->log->n("Account for '{$nick}' successfull registered");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
$this->log->e("Failed to register account for {$nick}");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function removeRequest(): bool {
|
private function removeRequest(): bool {
|
||||||
|
@ -109,6 +122,7 @@ class Registrator extends BaseClass {
|
||||||
$this->log->e("Error: {$e->getMessage()}");
|
$this->log->e("Error: {$e->getMessage()}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
$this->log->n("Request for {$nick} ($token) successfull removed");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue