jcs / rubywarden

An unofficial, mostly Bitwarden-compatible API server written in Ruby (Sinatra and ActiveRecord)
ISC License
593 stars 49 forks source link

Reset folder-ID of ciphers when deleting folder #49

Closed pc-coholic closed 6 years ago

pc-coholic commented 6 years ago

I recently deleted a folder containing quite a lot of entries using the Bitwarden Desktop-App.

The deletion of the folder itself worked without any issues, however it seems like bitwarden-ruby does not reset the folder-ID of the ciphers in question to NULL.

This causes a minor issue, as the ciphers are still available by searching for them, but they are not listed in the "No Folder"-section.

I manually fixed the issue by updating the database by hand - but it would be probably a good idea to do this automatically in the future and perhaps even offer a migration to fix "orphaned" ciphers.

universal commented 6 years ago

If you can, it would be great if you could contribute a test case for that (spec/folder_spec.rb) and the handling to the routing class: https://github.com/jcs/bitwarden-ruby/blob/master/lib/routes/api.rb#L278 or to the folder class and have a "before destroy" hook :-)

universal commented 6 years ago

Commit 92af2e19155f2da60204b9fd9758ba66f5eb1c9a in #52 fixes this problem, but this only works with the refactored code to active-record.

jcs commented 6 years ago

Should be fixed with the merging of #52