diff --git a/migrations/mysql/2023-09-14-133000_add_users_organizations_invited_by_email/down.sql b/migrations/mysql/2023-09-14-133000_add_users_organizations_invited_by_email/down.sql deleted file mode 100644 index 3a708927..00000000 --- a/migrations/mysql/2023-09-14-133000_add_users_organizations_invited_by_email/down.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE users_organizations DROP COLUMN invited_by_email; diff --git a/migrations/mysql/2023-09-14-133000_add_users_organizations_invited_by_email/up.sql b/migrations/mysql/2023-09-14-133000_add_users_organizations_invited_by_email/up.sql deleted file mode 100644 index c94e1131..00000000 --- a/migrations/mysql/2023-09-14-133000_add_users_organizations_invited_by_email/up.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE users_organizations ADD COLUMN invited_by_email TEXT DEFAULT NULL; diff --git a/migrations/postgresql/2023-09-14-133000_add_users_organizations_invited_by_email/down.sql b/migrations/postgresql/2023-09-14-133000_add_users_organizations_invited_by_email/down.sql deleted file mode 100644 index 3a708927..00000000 --- a/migrations/postgresql/2023-09-14-133000_add_users_organizations_invited_by_email/down.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE users_organizations DROP COLUMN invited_by_email; diff --git a/migrations/postgresql/2023-09-14-133000_add_users_organizations_invited_by_email/up.sql b/migrations/postgresql/2023-09-14-133000_add_users_organizations_invited_by_email/up.sql deleted file mode 100644 index c94e1131..00000000 --- a/migrations/postgresql/2023-09-14-133000_add_users_organizations_invited_by_email/up.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE users_organizations ADD COLUMN invited_by_email TEXT DEFAULT NULL; diff --git a/migrations/sqlite/2023-09-14-133000_add_users_organizations_invited_by_email/down.sql b/migrations/sqlite/2023-09-14-133000_add_users_organizations_invited_by_email/down.sql deleted file mode 100644 index 3a708927..00000000 --- a/migrations/sqlite/2023-09-14-133000_add_users_organizations_invited_by_email/down.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE users_organizations DROP COLUMN invited_by_email; diff --git a/migrations/sqlite/2023-09-14-133000_add_users_organizations_invited_by_email/up.sql b/migrations/sqlite/2023-09-14-133000_add_users_organizations_invited_by_email/up.sql deleted file mode 100644 index c94e1131..00000000 --- a/migrations/sqlite/2023-09-14-133000_add_users_organizations_invited_by_email/up.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE users_organizations ADD COLUMN invited_by_email TEXT DEFAULT NULL; diff --git a/src/api/core/organizations.rs b/src/api/core/organizations.rs index 8c118849..6793b68b 100644 --- a/src/api/core/organizations.rs +++ b/src/api/core/organizations.rs @@ -177,7 +177,7 @@ async fn create_organization(headers: Headers, data: Json, mut conn: Db }; let org = Organization::new(data.name, data.billing_email, private_key, public_key); - let mut user_org = UserOrganization::new(headers.user.uuid, org.uuid.clone(), None); + let mut user_org = UserOrganization::new(headers.user.uuid, org.uuid.clone()); let collection = Collection::new(org.uuid.clone(), data.collection_name, None); user_org.akey = data.key; @@ -955,8 +955,7 @@ async fn send_invite(org_id: &str, data: Json, headers: AdminHeaders } }; - let mut new_member = - UserOrganization::new(user.uuid.clone(), String::from(org_id), Some(headers.user.email.clone())); + let mut new_member = UserOrganization::new(user.uuid.clone(), String::from(org_id)); let access_all = data.access_all; new_member.access_all = access_all; new_member.atype = new_type; @@ -2127,12 +2126,10 @@ async fn import(org_id: &str, data: Json, headers: Headers, mut c UserOrgStatus::Accepted as i32 // Automatically mark user as accepted if no email invites }; - let mut new_member = - UserOrganization::new(user.uuid.clone(), String::from(org_id), Some(headers.user.email.clone())); + let mut new_member = UserOrganization::new(user.uuid.clone(), String::from(org_id)); new_member.access_all = false; new_member.atype = UserOrgType::User as i32; new_member.status = user_org_status; - new_member.save(&mut conn).await?; log_event( diff --git a/src/api/core/public.rs b/src/api/core/public.rs index 9a050f39..750236eb 100644 --- a/src/api/core/public.rs +++ b/src/api/core/public.rs @@ -110,12 +110,7 @@ async fn ldap_import(data: Json, token: PublicToken, mut conn: Db UserOrgStatus::Accepted as i32 // Automatically mark user as accepted if no email invites }; - let (org_name, org_email) = match Organization::find_by_uuid(&org_id, &mut conn).await { - Some(org) => (org.name, org.billing_email), - None => err!("Error looking up organization"), - }; - - let mut new_member = UserOrganization::new(user.uuid.clone(), org_id.clone(), Some(org_email.clone())); + let mut new_member = UserOrganization::new(user.uuid.clone(), org_id.clone()); new_member.set_external_id(Some(user_data.external_id.clone())); new_member.access_all = false; new_member.atype = UserOrgType::User as i32; @@ -124,6 +119,11 @@ async fn ldap_import(data: Json, token: PublicToken, mut conn: Db new_member.save(&mut conn).await?; if CONFIG.mail_enabled() { + let (org_name, org_email) = match Organization::find_by_uuid(&org_id, &mut conn).await { + Some(org) => (org.name, org.billing_email), + None => err!("Error looking up organization"), + }; + if let Err(e) = mail::send_invite( &user, Some(org_id.clone()), diff --git a/src/db/models/organization.rs b/src/db/models/organization.rs index 17098871..2ee86512 100644 --- a/src/db/models/organization.rs +++ b/src/db/models/organization.rs @@ -29,7 +29,6 @@ db_object! { pub uuid: String, pub user_uuid: String, pub org_uuid: String, - pub invited_by_email: Option, pub access_all: bool, pub akey: String, @@ -216,13 +215,12 @@ impl Organization { static ACTIVATE_REVOKE_DIFF: i32 = 128; impl UserOrganization { - pub fn new(user_uuid: String, org_uuid: String, invited_by_email: Option) -> Self { + pub fn new(user_uuid: String, org_uuid: String) -> Self { Self { uuid: crate::util::get_uuid(), user_uuid, org_uuid, - invited_by_email, access_all: false, akey: String::new(), diff --git a/src/db/schemas/mysql/schema.rs b/src/db/schemas/mysql/schema.rs index 89c4a4d1..f5446ff2 100644 --- a/src/db/schemas/mysql/schema.rs +++ b/src/db/schemas/mysql/schema.rs @@ -234,7 +234,6 @@ table! { uuid -> Text, user_uuid -> Text, org_uuid -> Text, - invited_by_email -> Nullable, access_all -> Bool, akey -> Text, status -> Integer, diff --git a/src/db/schemas/postgresql/schema.rs b/src/db/schemas/postgresql/schema.rs index 517fe0c2..07792e1e 100644 --- a/src/db/schemas/postgresql/schema.rs +++ b/src/db/schemas/postgresql/schema.rs @@ -234,7 +234,6 @@ table! { uuid -> Text, user_uuid -> Text, org_uuid -> Text, - invited_by_email -> Nullable, access_all -> Bool, akey -> Text, status -> Integer, diff --git a/src/db/schemas/sqlite/schema.rs b/src/db/schemas/sqlite/schema.rs index 517fe0c2..07792e1e 100644 --- a/src/db/schemas/sqlite/schema.rs +++ b/src/db/schemas/sqlite/schema.rs @@ -234,7 +234,6 @@ table! { uuid -> Text, user_uuid -> Text, org_uuid -> Text, - invited_by_email -> Nullable, access_all -> Bool, akey -> Text, status -> Integer,