Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/notifications.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-01-26 13:36:30 +0300
committerJoas Schilling <coding@schilljs.com>2017-03-29 11:59:16 +0300
commit08ea5ffff4485478a85b363c8eb4ced987481c6b (patch)
treef9befcbc97a50613da178b60dee5daa1df609c50 /lib/Controller/PushController.php
parentebaa6d1a24088162d6b30e93fee9847cba1cfb97 (diff)
Error when on deletion the device public key is wrong as well
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Controller/PushController.php')
-rw-r--r--lib/Controller/PushController.php15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/Controller/PushController.php b/lib/Controller/PushController.php
index ce8cd73..68675cf 100644
--- a/lib/Controller/PushController.php
+++ b/lib/Controller/PushController.php
@@ -150,7 +150,12 @@ class PushController extends OCSController {
return new JSONResponse(['message' => 'Could not identify session token'], Http::STATUS_BAD_REQUEST);
}
- $this->deletePushToken($user, $token, $devicePublicKey);
+ try {
+ $this->deletePushToken($user, $token, $devicePublicKey);
+ } catch (\BadMethodCallException $e) {
+ return new JSONResponse(['message' => 'Invalid device public key'], Http::STATUS_BAD_REQUEST);
+ }
+
return new JSONResponse();
}
@@ -233,6 +238,7 @@ class PushController extends OCSController {
* @param IToken $token
* @param string $devicePublicKey
* @return bool If the entry was deleted
+ * @throws \BadMethodCallException
*/
protected function deletePushToken(IUser $user, IToken $token, $devicePublicKey) {
$devicePublicKeyHash = hash('sha512', $devicePublicKey);
@@ -242,6 +248,11 @@ class PushController extends OCSController {
->where($query->expr()->eq('uid', $query->createNamedParameter($user->getUID())))
->andWhere($query->expr()->eq('token', $query->createNamedParameter($token->getId(), IQueryBuilder::PARAM_INT)))
->andWhere($query->expr()->eq('devicepublickeyhash', $query->createNamedParameter($devicePublicKeyHash)));
- return $query->execute() > 0;
+
+ if ($query->execute() !== 0) {
+ throw new \BadMethodCallException();
+ }
+
+ return true;
}
}