Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2024-11-25 05:40:29 +01:00
Added read_only bit to users_collections
Dieser Commit ist enthalten in:
Ursprung
0cb58add54
Commit
79b4ddcae8
5 geänderte Dateien mit 24 neuen und 22 gelöschten Zeilen
0
migrations/2018-04-27-155151_create_users_ciphers/down.sql
Normale Datei
0
migrations/2018-04-27-155151_create_users_ciphers/down.sql
Normale Datei
|
@ -29,4 +29,6 @@ INSERT INTO folders_ciphers (cipher_uuid, folder_uuid)
|
||||||
SELECT uuid, folder_uuid FROM oldCiphers WHERE folder_uuid IS NOT NULL;
|
SELECT uuid, folder_uuid FROM oldCiphers WHERE folder_uuid IS NOT NULL;
|
||||||
|
|
||||||
|
|
||||||
DROP TABLE oldCiphers;
|
DROP TABLE oldCiphers;
|
||||||
|
|
||||||
|
ALTER TABLE users_collections ADD COLUMN read_only BOOLEAN NOT NULL DEFAULT 0; -- False
|
||||||
|
|
|
@ -150,7 +150,7 @@ fn post_organization_collections(org_id: String, headers: Headers, data: Json<Ne
|
||||||
collection.save(&conn);
|
collection.save(&conn);
|
||||||
|
|
||||||
if !org_user.access_all {
|
if !org_user.access_all {
|
||||||
CollectionUsers::save(&headers.user.uuid, &collection.uuid, &conn);
|
CollectionUsers::save(&headers.user.uuid, &collection.uuid, false, &conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Json(collection.to_json()))
|
Ok(Json(collection.to_json()))
|
||||||
|
@ -308,10 +308,8 @@ fn send_invite(org_id: String, data: Json<InviteData>, headers: Headers, conn: D
|
||||||
// If no accessAll, add the collections received
|
// If no accessAll, add the collections received
|
||||||
if !data.accessAll {
|
if !data.accessAll {
|
||||||
for collection in data.collections.iter() {
|
for collection in data.collections.iter() {
|
||||||
// TODO: Check that collection is in org
|
// TODO: Check that collection is in org
|
||||||
// TODO: Save the readOnly bit
|
CollectionUsers::save(&headers.user.uuid, &collection.id, collection.readOnly, &conn);
|
||||||
|
|
||||||
CollectionUsers::save(&headers.user.uuid, &collection.id, &conn);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,10 +441,8 @@ fn edit_user(org_id: String, user_id: String, data: Json<EditUserData>, headers:
|
||||||
// If no accessAll, add the collections received
|
// If no accessAll, add the collections received
|
||||||
if !data.accessAll {
|
if !data.accessAll {
|
||||||
for collection in data.collections.iter() {
|
for collection in data.collections.iter() {
|
||||||
// TODO: Check that collection is in org
|
// TODO: Check that collection is in org
|
||||||
// TODO: Save the readOnly bit
|
CollectionUsers::save(¤t_user.uuid, &collection.id, collection.readOnly, &conn);
|
||||||
|
|
||||||
CollectionUsers::save(¤t_user.uuid, &collection.id, &conn);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,15 +106,17 @@ use super::User;
|
||||||
pub struct CollectionUsers {
|
pub struct CollectionUsers {
|
||||||
pub user_uuid: String,
|
pub user_uuid: String,
|
||||||
pub collection_uuid: String,
|
pub collection_uuid: String,
|
||||||
|
pub read_only: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Database methods
|
/// Database methods
|
||||||
impl CollectionUsers {
|
impl CollectionUsers {
|
||||||
pub fn save(user_uuid: &str, collection_uuid: &str, conn: &DbConn) -> bool {
|
pub fn save(user_uuid: &str, collection_uuid: &str, read_only:bool, conn: &DbConn) -> bool {
|
||||||
match diesel::replace_into(users_collections::table)
|
match diesel::replace_into(users_collections::table)
|
||||||
.values((
|
.values((
|
||||||
users_collections::user_uuid.eq(user_uuid),
|
users_collections::user_uuid.eq(user_uuid),
|
||||||
users_collections::collection_uuid.eq(collection_uuid)
|
users_collections::collection_uuid.eq(collection_uuid),
|
||||||
|
users_collections::read_only.eq(read_only),
|
||||||
)).execute(&**conn) {
|
)).execute(&**conn) {
|
||||||
Ok(1) => true, // One row inserted
|
Ok(1) => true, // One row inserted
|
||||||
_ => false,
|
_ => false,
|
||||||
|
|
|
@ -56,6 +56,13 @@ table! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table! {
|
||||||
|
folders_ciphers (cipher_uuid, folder_uuid) {
|
||||||
|
cipher_uuid -> Text,
|
||||||
|
folder_uuid -> Text,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
table! {
|
table! {
|
||||||
organizations (uuid) {
|
organizations (uuid) {
|
||||||
uuid -> Text,
|
uuid -> Text,
|
||||||
|
@ -90,6 +97,7 @@ table! {
|
||||||
users_collections (user_uuid, collection_uuid) {
|
users_collections (user_uuid, collection_uuid) {
|
||||||
user_uuid -> Text,
|
user_uuid -> Text,
|
||||||
collection_uuid -> Text,
|
collection_uuid -> Text,
|
||||||
|
read_only -> Bool,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,24 +114,18 @@ table! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
table! {
|
|
||||||
folders_ciphers (cipher_uuid, folder_uuid) {
|
|
||||||
cipher_uuid -> Text,
|
|
||||||
folder_uuid -> Text,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
joinable!(attachments -> ciphers (cipher_uuid));
|
joinable!(attachments -> ciphers (cipher_uuid));
|
||||||
|
joinable!(ciphers -> organizations (organization_uuid));
|
||||||
joinable!(ciphers -> users (user_uuid));
|
joinable!(ciphers -> users (user_uuid));
|
||||||
joinable!(collections -> organizations (org_uuid));
|
joinable!(collections -> organizations (org_uuid));
|
||||||
joinable!(devices -> users (user_uuid));
|
joinable!(devices -> users (user_uuid));
|
||||||
joinable!(folders -> users (user_uuid));
|
joinable!(folders -> users (user_uuid));
|
||||||
|
joinable!(folders_ciphers -> ciphers (cipher_uuid));
|
||||||
|
joinable!(folders_ciphers -> folders (folder_uuid));
|
||||||
joinable!(users_collections -> collections (collection_uuid));
|
joinable!(users_collections -> collections (collection_uuid));
|
||||||
joinable!(users_collections -> users (user_uuid));
|
joinable!(users_collections -> users (user_uuid));
|
||||||
joinable!(users_organizations -> organizations (org_uuid));
|
joinable!(users_organizations -> organizations (org_uuid));
|
||||||
joinable!(users_organizations -> users (user_uuid));
|
joinable!(users_organizations -> users (user_uuid));
|
||||||
joinable!(folders_ciphers -> ciphers (cipher_uuid));
|
|
||||||
joinable!(folders_ciphers -> folders (folder_uuid));
|
|
||||||
|
|
||||||
allow_tables_to_appear_in_same_query!(
|
allow_tables_to_appear_in_same_query!(
|
||||||
attachments,
|
attachments,
|
||||||
|
@ -131,9 +133,9 @@ allow_tables_to_appear_in_same_query!(
|
||||||
collections,
|
collections,
|
||||||
devices,
|
devices,
|
||||||
folders,
|
folders,
|
||||||
|
folders_ciphers,
|
||||||
organizations,
|
organizations,
|
||||||
users,
|
users,
|
||||||
users_collections,
|
users_collections,
|
||||||
users_organizations,
|
users_organizations,
|
||||||
folders_ciphers,
|
|
||||||
);
|
);
|
||||||
|
|
Laden …
In neuem Issue referenzieren