mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-06-09 12:33:53 +00:00
Implement suggested improvements
This commit is contained in:
parent
c3be1b4298
commit
a0796acbc7
5 changed files with 7 additions and 8 deletions
|
@ -222,10 +222,10 @@ impl UserOrganization {
|
|||
.first::<Self>(&**conn).ok()
|
||||
}
|
||||
|
||||
pub fn find_by_user(user_uuid: &str, conn: &DbConn) -> Option<Vec<Self>> {
|
||||
pub fn find_by_user(user_uuid: &str, conn: &DbConn) -> Vec<Self> {
|
||||
users_organizations::table
|
||||
.filter(users_organizations::user_uuid.eq(user_uuid))
|
||||
.load::<Self>(&**conn).ok()
|
||||
.load::<Self>(&**conn).unwrap_or(vec![])
|
||||
}
|
||||
|
||||
pub fn find_by_org(org_uuid: &str, conn: &DbConn) -> Vec<Self> {
|
||||
|
|
|
@ -128,7 +128,7 @@ impl User {
|
|||
pub fn to_json(&self, conn: &DbConn) -> JsonValue {
|
||||
use super::UserOrganization;
|
||||
|
||||
let orgs = UserOrganization::find_by_user(&self.uuid, conn).unwrap_or(vec![]);
|
||||
let orgs = UserOrganization::find_by_user(&self.uuid, conn);
|
||||
let orgs_json: Vec<JsonValue> = orgs.iter().map(|c| c.to_json(&conn)).collect();
|
||||
|
||||
json!({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue