diff --git a/MatrixConnection.php b/MatrixConnection.php index 1ae1f81..815b0dc 100644 --- a/MatrixConnection.php +++ b/MatrixConnection.php @@ -103,7 +103,15 @@ class MatrixConnection { curl_setopt($handle, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); curl_setopt($handle, CURLOPT_POSTFIELDS, json_encode($data)); - return $this->exec_curl_request($handle); + try { + return $this->exec_curl_request($handle); + } catch (Exception $e) { + if (strcmp("AUTHENTICATION_FAILED", $e->getMessage()) == 0) { + throw new Exception("WRONG_REGISTRATION_SHARED_SECRET"); + } else { + throw $e; + } + } } function exec_curl_request($handle) { @@ -126,7 +134,7 @@ class MatrixConnection { $response = json_decode($response, true); error_log("Request has failed with error {$response['error']}\n"); if ($http_code == 401) { - throw new Exception('Invalid access token provided'); + throw new Exception("AUTHENTICATION_FAILED"); } } else { $response = json_decode($response, true); diff --git a/lang/lang.de-de.php b/lang/lang.de-de.php index 934bfad..87f4c3f 100644 --- a/lang/lang.de-de.php +++ b/lang/lang.de-de.php @@ -31,6 +31,8 @@ $language = array( "UNKNOWN_SESSION" => "Sitzungstoken nicht vorhanden oder ungültig.", "UNKNOWN_USERNAME" => "Nutzername fehlt", "UNKNOWN_TOKEN" => "Token ist unbekannt", + "AUTHENTICATION_FAILED" => "Authentifizierung fehlgeschlagen", + "WRONG_REGISTRATION_SHARED_SECRET" => "registration_shared_secret fehlerhaft", "USERNAME_INVALID" => "Nutzername muss aus 3 bis 20 Kleinbuchstaben bestehen", "USERNAME_NOT_ALNUM" => "Nutzername ist nicht alphanumerisch", "USERNAME_PENDING_REGISTRATION" => "Dieser Nutzername wurde bereits zur Registrierung vorgemerkt. Versuche es später noch einmal oder wähle einen anderen Nutzernamen", diff --git a/lang/lang.en-gb.php b/lang/lang.en-gb.php index af4523b..54fae67 100644 --- a/lang/lang.en-gb.php +++ b/lang/lang.en-gb.php @@ -31,6 +31,8 @@ $language = array( "UNKNOWN_SESSION" => "Session token not found of invalid.", "UNKNOWN_USERNAME" => "username unknown", "UNKNOWN_TOKEN" => "Token is unknown", + "AUTHENTICATION_FAILED" => "Authentication failed", + "WRONG_REGISTRATION_SHARED_SECRET" => "wrong registration_shared_secret", "USERNAME_INVALID" => "Username has to consist of 3 to 20 small letters", "USERNAME_NOT_ALNUM" => "Username is not alphanumeric", "USERNAME_PENDING_REGISTRATION" => "This username is locked for registration. Try again later or try again with a different username",