marius-wieschollek / passwords

A simple, yet feature rich password manager for Nextcloud
GNU Affero General Public License v3.0
210 stars 44 forks source link

[BUG]: Resource not found -> when the original user who create the password and share it is now deleted #587

Open CypLef opened 1 year ago

CypLef commented 1 year ago

⚠️ This issue respects the following points: ⚠️

Server Information

{
    "version": {
        "server": "25.0.3.2",
        "app": "2023.2.22",
        "lsr": false,
        "php": "8.1.16",
        "cronPhp": "8.1.16"
    },
    "environment": {
        "os": "Linux",
        "architecture": "x86_64",
        "bits": 64,
        "database": "mysql",
        "cron": "cron",
        "proxy": false,
        "sslProxy": false,
        "subdirectory": false
    },
    "services": {
        "images": "imagick",
        "favicons": "default",
        "previews": "default",
        "security": "hibp",
        "words": "leipzig",
        "previewApi": false,
        "faviconApi": false
    },
    "status": {
        "autoBackupRestored": false
    },
    "settings": {
        "channel": "stable",
        "nightlies": false,
        "handbook": false,
        "performance": 5
    },
    "encryption": {
        "sse": {
            "SSEv1r1": false,
            "SSEv1r2": true,
            "SSEv2r1": false,
            "SSEv3r1": false,
            "none": true,
            "default": "SSEv1r2"
        },
        "cse": {
            "CSEv1r1": true,
            "none": true,
            "default": "none"
        }
    }
}

Client Information

Browser and Version: Firefox V 111.0.1 (64 bits) Client OS and Version: Ubuntu 20.04 LTS

Bug description

When i try to share a password that a user (now deleted) shared to me, i have a bug: Resource not found image

Steps to reproduce

  1. Create user 1
  2. User 1 create password 1
  3. User 1 share password 1 to User 2
  4. User Admin delete the NC account of User 1
  5. User 2 try to share the password to User 3
  6. The bug appear

Note: User 2 can still see and use the Password 1, but can't share it

Expected behavior

It should be possible to edit and share Password 1 without having to create a new one.

Option 1: Create a way to transfer the ownership of the password to another user (like for nextcloud file)

Nextcloud Logs

[passwords] Fatal: OCP\AppFramework\Db\DoesNotExistException: Did expect one result but found none when executing: query "SELECT * FROM `*PREFIX*passwords_share` WHERE (`deleted` = :dcValue1) AND ((`user_id` = :dcValue2) OR ((`receiver` = :dcValue3) AND (`target_password` IS NOT NULL))) AND (`uuid` = :dcValue4)";  at <<closure>>

 0. /var/www/html/nextcloud/lib/public/AppFramework/Db/QBMapper.php line 362
    OCP\AppFramework\Db\QBMapper->findOneQuery()
 1. /var/www/html/nextcloud/apps/passwords/lib/Db/AbstractMapper.php line 194
    OCP\AppFramework\Db\QBMapper->findEntity()
 2. /var/www/html/nextcloud/apps/passwords/lib/Db/AbstractMapper.php line 167
    OCA\Passwords\Db\AbstractMapper->findOneByFields()
 3. /var/www/html/nextcloud/apps/passwords/lib/Db/AbstractMapper.php line 107
    OCA\Passwords\Db\AbstractMapper->findOneByField()
 4. /var/www/html/nextcloud/apps/passwords/lib/Services/Object/ShareService.php line 155
    OCA\Passwords\Db\AbstractMapper->findByUuid()
 5. /var/www/html/nextcloud/apps/passwords/lib/Helper/ApiObjects/PasswordObjectHelper.php line 293
    OCA\Passwords\Services\Object\ShareService->findByUuid()
 6. /var/www/html/nextcloud/apps/passwords/lib/Helper/ApiObjects/PasswordObjectHelper.php line 129
    OCA\Passwords\Helper\ApiObjects\PasswordObjectHelper->getShares()
 7. /var/www/html/nextcloud/apps/passwords/lib/Controller/Api/AbstractObjectApiController.php line 145
    OCA\Passwords\Helper\ApiObjects\PasswordObjectHelper->getApiObject()
 8. /var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 225
    OCA\Passwords\Controller\Api\AbstractObjectApiController->show()
 9. /var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 133
    OC\AppFramework\Http\Dispatcher->executeController()
10. /var/www/html/nextcloud/lib/private/AppFramework/App.php line 172
    OC\AppFramework\Http\Dispatcher->dispatch()
11. /var/www/html/nextcloud/lib/private/Route/Router.php line 298
    OC\AppFramework\App::main()
12. /var/www/html/nextcloud/lib/base.php line 1047
    OC\Route\Router->match()
13. /var/www/html/nextcloud/index.php line 36
    OC::handleRequest()

POST /index.php/apps/passwords/api/1.0/password/show
from 93.0.57.167 by Cyprien at 2023-04-05T17:21:56+00:00

-----

[passwords] Erreur: Error "Did expect one result but found none when executing: query "SELECT * FROM `*PREFIX*passwords_share` WHERE (`deleted` = :dcValue1) AND ((`user_id` = :dcValue2) OR ((`receiver` = :dcValue3) AND (`target_password` IS NOT NULL))) AND (`uuid` = :dcValue4)"; " in OCA\Passwords\Controller\Api\PasswordApiController::show

POST /index.php/apps/passwords/api/1.0/password/show
from 93.0.57.167 by Cyprien at 2023-04-05T17:21:56+00:00

Browser Logs

No response

mokkin commented 1 year ago

I have the same issue here.

marius-wieschollek commented 1 year ago

I will look into this. But FYI: If a user gets deleted, the intended process is to delete all their data.