Beispiel #1
0
 public function delete($userId, $grantId)
 {
     $grant = $this->userGrantTable->get($grantId);
     if (!empty($grant)) {
         if ($grant['userId'] == $userId) {
             try {
                 $this->userGrantTable->beginTransaction();
                 $this->userGrantTable->delete($grant);
                 // delete tokens
                 $this->appTokenTable->removeAllTokensFromAppAndUser($grant['appId'], $grant['userId']);
                 $this->userGrantTable->commit();
             } catch (\Exception $e) {
                 $this->userGrantTable->rollBack();
                 throw $e;
             }
         } else {
             throw new StatusCode\BadRequestException('Invalid grant id');
         }
     } else {
         throw new StatusCode\NotFoundException('Could not find grant');
     }
 }