Compare commits
3 Commits
6d19d869c8
...
feature_mu
| Author | SHA1 | Date | |
|---|---|---|---|
| 5eeaa11c0c | |||
| f74a2f74e0 | |||
| 53ccd1c2b3 |
@@ -19,6 +19,10 @@ $config = [
|
||||
// - local (recommended; using a table in the database to store credentials;
|
||||
// synapse has to be configured to use that)
|
||||
"operationMode" => "local",
|
||||
|
||||
// This setting is only required for operationMode = synapse
|
||||
"registration_shared_secret" => "SOME_SECRET_KEY_FROM_HOMESERVER_CONFIG",
|
||||
|
||||
// When you want to collect the password on registration set this to true
|
||||
// only evaluated when operationMode = local
|
||||
"getPasswordOnRegistration" => false,
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
function send_mail($receiver, $subject, $body) {
|
||||
include("config.php");
|
||||
include("../config.php");
|
||||
$headers = "From: " . $config["register_email"] . "\r\n"
|
||||
. "Content-Type: text/plain;charset=utf-8";
|
||||
return mail($receiver, $subject, $body, $headers);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
function send_mail($receiver, $subject, $body) {
|
||||
include("config.php");
|
||||
include("../config.php");
|
||||
$headers = "From: " . $config["register_email"] . "\r\n"
|
||||
. "Content-Type: text/plain;charset=utf-8";
|
||||
return mail($receiver, $subject, $body, $headers);
|
||||
|
||||
@@ -28,4 +28,4 @@ if (!file_exists($lang_file)) {
|
||||
$lang_file = dirname(__FILE__) . "/lang/lang." . $lang . ".php";
|
||||
require_once($lang_file);
|
||||
unset($lang_file);
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -70,8 +70,25 @@ try {
|
||||
require_once("../MatrixConnection.php");
|
||||
$mxConn = new MatrixConnection($config["homeserver"], $config["access_token"]);
|
||||
|
||||
// generate a password with 8 characters
|
||||
$password = $mx_db->addUser($first_name, $last_name, $username, $email);
|
||||
$password = NULL;
|
||||
switch ($config["operationMode"]) {
|
||||
case "synapse":
|
||||
// register with registration_shared_secret
|
||||
// generate a password with 10 characters
|
||||
$password = bin2hex(openssl_random_pseudo_bytes(5));
|
||||
$res = $mxConn->register($username, $password, $config["registration_shared_secret"]);
|
||||
if (!$res) {
|
||||
// something went wrong while registering
|
||||
$password = NULL;
|
||||
}
|
||||
break;
|
||||
case "local":
|
||||
// register by adding a user to the local database
|
||||
$password = $mx_db->addUser($first_name, $last_name, $username, $email);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Unknown operationMode");
|
||||
}
|
||||
if ($password != NULL) {
|
||||
// send registration_success
|
||||
$res = send_mail_registration_success(
|
||||
|
||||
Reference in New Issue
Block a user