diff --git a/database.php b/database.php index 81ee122..9459975 100644 --- a/database.php +++ b/database.php @@ -306,7 +306,7 @@ class mxDatabase function updatePassword($localpart, $old_password, $new_password) { $user = $this->getUserForLogin($localpart, $old_password); - if ($user != NULL) { + if ($user == NULL) { throw new Exception ("user with that credentials not found"); } diff --git a/internal/intercept_change_password.php b/internal/intercept_change_password.php index 36d1b9e..7d8de8a 100644 --- a/internal/intercept_change_password.php +++ b/internal/intercept_change_password.php @@ -15,18 +15,16 @@ */ // URL for this: /_matrix/client/r0/account/password?access_token=$ACCESS_TOKEN -$response=[ - "errcode" => "M_UNKNOWN", - "error" => "Unknown error while handling password changing", -]; + header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: POST, OPTIONS'); header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization'); if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { - $response = []; + print ("{}"); // return with success exit(); } +$response= new stdClass; try { $inputJSON = file_get_contents('php://input'); $input = json_decode($inputJSON, TRUE); @@ -54,20 +52,21 @@ try { } require_once("../database.php"); - if ($mx_db->updatePassword( + if (!$mx_db->updatePassword( $localpart, $input["auth"]["password"], $input["new_password"] )) { - $response=[]; - } else { throw new Exception("invalid credentials or another error while updating"); } } catch (Exception $e) { header("HTTP/1.0 500 Internal Error"); error_log("failed with error: " . $e->getMessage()); - $response["error"] = $e->getMessage(); + $response = [ + "errorcode" => "M_UNKNOWN", + "error" => $e->getMessage(), + ]; } -print (json_encode($response, JSON_PRETTY_PRINT) . "\n"); +print (json_encode($response, JSON_PRETTY_PRINT)); ?> diff --git a/mail_templates.php b/mail_templates.php index 550a7cc..951d94c 100644 --- a/mail_templates.php +++ b/mail_templates.php @@ -81,8 +81,8 @@ Zum Anmelden kannst du folgende Zugangsdaten verwenden: Nutzername: $username Passwort: $password -Hinweis: Aktuell ist es nicht möglich, das Passwort selbst zu ändern. Sobald die Funktionalität zur -Verfügung steht, gibt es aber einen Hinweis. +Hinweis: Das Passwort kannst du aktuell über die App selbst ändern. Auch wenn das Passwort nirgends +im Klartext gespeichert wird, kann jemand Zugriff auf diese Mail erlangen und so den Zugriff bekommen. "; /* Wichtig: Bitte ändere das Passwort direkt nach der Anmeldung.