vw_small

Hardened fork of Vaultwarden (https://github.com/dani-garcia/vaultwarden) with fewer features.
git clone https://git.philomathiclife.com/repos/vw_small
Log | Files | Refs | README

commit c4360ee6976bdbb5223cab3da09d8d53d6dfefba
parent a0796acbc73e8e7b9bcd94bab334cc82aa922835
Author: Miroslav Prasil <miroslav@prasil.info>
Date:   Fri,  4 May 2018 13:42:30 +0100

Save extra query when checking write access

Diffstat:
Msrc/db/models/cipher.rs | 7++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/db/models/cipher.rs b/src/db/models/cipher.rs @@ -183,11 +183,8 @@ impl Cipher { } pub fn is_write_accessible_to_user(&self, user_uuid: &str, conn: &DbConn) -> bool { - match ciphers::table - .filter(ciphers::user_uuid.eq(user_uuid)) - .filter(ciphers::uuid.eq(&self.uuid)) - .first::<Self>(&**conn).ok() { - Some(_) => true, // cipher directly owned by user + match self.user_uuid { + Some(ref self_user_uuid) => self_user_uuid == user_uuid, // cipher directly owned by user None =>{ match self.organization_uuid { Some(ref org_uuid) => {