mirror of
https://github.com/dani-garcia/vaultwarden
synced 2024-11-17 23:43:32 +01:00
Save extra query when checking write access
This commit is contained in:
parent
a0796acbc7
commit
c4360ee697
1 changed files with 2 additions and 5 deletions
|
@ -183,11 +183,8 @@ impl Cipher {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_write_accessible_to_user(&self, user_uuid: &str, conn: &DbConn) -> bool {
|
pub fn is_write_accessible_to_user(&self, user_uuid: &str, conn: &DbConn) -> bool {
|
||||||
match ciphers::table
|
match self.user_uuid {
|
||||||
.filter(ciphers::user_uuid.eq(user_uuid))
|
Some(ref self_user_uuid) => self_user_uuid == user_uuid, // cipher directly owned by user
|
||||||
.filter(ciphers::uuid.eq(&self.uuid))
|
|
||||||
.first::<Self>(&**conn).ok() {
|
|
||||||
Some(_) => true, // cipher directly owned by user
|
|
||||||
None =>{
|
None =>{
|
||||||
match self.organization_uuid {
|
match self.organization_uuid {
|
||||||
Some(ref org_uuid) => {
|
Some(ref org_uuid) => {
|
||||||
|
|
Loading…
Reference in a new issue