1
0
Fork 1
Spiegel von https://github.com/dani-garcia/vaultwarden.git synchronisiert 2024-11-29 06:20:29 +01:00

fix invitations of new users when mail is disabled

If you add a new user that has already been Invited to another
organization they will be Accepted automatically. This should not be
possible because they cannot be Confirmed until they have completed
their registration. It is also not necessary because their invitation
will be accepted automatically once they register.
Dieser Commit ist enthalten in:
Stefan Melmuk 2022-09-27 23:19:35 +02:00 committet von Daniel García
Ursprung f41ba2a60f
Commit 6576914e55
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: FC8A7D14C3CD543A

Datei anzeigen

@ -600,11 +600,7 @@ async fn send_invite(org_id: String, data: JsonUpcase<InviteData>, headers: Admi
for email in data.Emails.iter() { for email in data.Emails.iter() {
let email = email.to_lowercase(); let email = email.to_lowercase();
let mut user_org_status = if CONFIG.mail_enabled() { let mut user_org_status = UserOrgStatus::Invited as i32;
UserOrgStatus::Invited as i32
} else {
UserOrgStatus::Accepted as i32 // Automatically mark user as accepted if no email invites
};
let user = match User::find_by_mail(&email, &conn).await { let user = match User::find_by_mail(&email, &conn).await {
None => { None => {
if !CONFIG.invitations_allowed() { if !CONFIG.invitations_allowed() {
@ -622,13 +618,16 @@ async fn send_invite(org_id: String, data: JsonUpcase<InviteData>, headers: Admi
let mut user = User::new(email.clone()); let mut user = User::new(email.clone());
user.save(&conn).await?; user.save(&conn).await?;
user_org_status = UserOrgStatus::Invited as i32;
user user
} }
Some(user) => { Some(user) => {
if UserOrganization::find_by_user_and_org(&user.uuid, &org_id, &conn).await.is_some() { if UserOrganization::find_by_user_and_org(&user.uuid, &org_id, &conn).await.is_some() {
err!(format!("User already in organization: {}", email)) err!(format!("User already in organization: {}", email))
} else { } else {
// automatically accept existing users if mail is disabled
if !CONFIG.mail_enabled() && !user.password_hash.is_empty() {
user_org_status = UserOrgStatus::Accepted as i32;
}
user user
} }
} }