fix password setting via android; update mail_template to show that you can set passwords

This commit is contained in:
2018-03-26 19:26:14 +02:00
parent 4f76e45ae5
commit 6f6ad7bccb
3 changed files with 12 additions and 13 deletions

View File

@@ -306,7 +306,7 @@ class mxDatabase
function updatePassword($localpart, $old_password, $new_password) { function updatePassword($localpart, $old_password, $new_password) {
$user = $this->getUserForLogin($localpart, $old_password); $user = $this->getUserForLogin($localpart, $old_password);
if ($user != NULL) { if ($user == NULL) {
throw new Exception ("user with that credentials not found"); throw new Exception ("user with that credentials not found");
} }

View File

@@ -15,18 +15,16 @@
*/ */
// URL for this: /_matrix/client/r0/account/password?access_token=$ACCESS_TOKEN // 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-Origin: *');
header('Access-Control-Allow-Methods: POST, OPTIONS'); header('Access-Control-Allow-Methods: POST, OPTIONS');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization'); header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization');
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
$response = []; print ("{}");
// return with success // return with success
exit(); exit();
} }
$response= new stdClass;
try { try {
$inputJSON = file_get_contents('php://input'); $inputJSON = file_get_contents('php://input');
$input = json_decode($inputJSON, TRUE); $input = json_decode($inputJSON, TRUE);
@@ -54,20 +52,21 @@ try {
} }
require_once("../database.php"); require_once("../database.php");
if ($mx_db->updatePassword( if (!$mx_db->updatePassword(
$localpart, $localpart,
$input["auth"]["password"], $input["auth"]["password"],
$input["new_password"] $input["new_password"]
)) { )) {
$response=[];
} else {
throw new Exception("invalid credentials or another error while updating"); throw new Exception("invalid credentials or another error while updating");
} }
} catch (Exception $e) { } catch (Exception $e) {
header("HTTP/1.0 500 Internal Error"); header("HTTP/1.0 500 Internal Error");
error_log("failed with error: " . $e->getMessage()); 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));
?> ?>

View File

@@ -81,8 +81,8 @@ Zum Anmelden kannst du folgende Zugangsdaten verwenden:
Nutzername: $username Nutzername: $username
Passwort: $password Passwort: $password
Hinweis: Aktuell ist es nicht möglich, das Passwort selbst zu ändern. Sobald die Funktionalität zur Hinweis: Das Passwort kannst du aktuell über die App selbst ändern. Auch wenn das Passwort nirgends
Verfügung steht, gibt es aber einen Hinweis. 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. Wichtig: Bitte ändere das Passwort direkt nach der Anmeldung.