geforkt von mirrored/vaultwarden
Use new Errors in latest changes
Dieser Commit ist enthalten in:
Ursprung
b2fc0499f6
Commit
250a2b340f
3 geänderte Dateien mit 7 neuen und 16 gelöschten Zeilen
|
@ -446,23 +446,16 @@ fn send_invite(org_id: String, data: JsonUpcase<InviteData>, headers: AdminHeade
|
||||||
|
|
||||||
new_user.save(&conn)?;
|
new_user.save(&conn)?;
|
||||||
|
|
||||||
if CONFIG.mail.is_some() {
|
if let Some(ref mail_config) = CONFIG.mail {
|
||||||
let org_name = match Organization::find_by_uuid(&org_id, &conn) {
|
let org_name = match Organization::find_by_uuid(&org_id, &conn) {
|
||||||
Some(org) => org.name,
|
Some(org) => org.name,
|
||||||
None => err!("Error looking up organization")
|
None => err!("Error looking up organization")
|
||||||
};
|
};
|
||||||
let claims = generate_invite_claims(user.uuid.to_string(), user.email.clone(), org_id.clone(), Some(new_user.uuid.clone()));
|
let claims = generate_invite_claims(user.uuid.to_string(), user.email.clone(), org_id.clone(), Some(new_user.uuid.clone()));
|
||||||
let invite_token = encode_jwt(&claims);
|
let invite_token = encode_jwt(&claims);
|
||||||
if let Some(ref mail_config) = CONFIG.mail {
|
mail::send_invite(&email, &org_id, &new_user.uuid, &invite_token, &org_name, mail_config)?;
|
||||||
if let Err(e) = mail::send_invite(&email, &org_id, &new_user.uuid,
|
|
||||||
&invite_token, &org_name, mail_config) {
|
|
||||||
err!(format!("There has been a problem sending the email: {}", e))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
new_user.save(&conn)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -499,9 +492,7 @@ fn reinvite_user(org_id: String, user_org: String, _headers: AdminHeaders, conn:
|
||||||
let claims = generate_invite_claims(user.uuid.to_string(), user.email.clone(), org_id.clone(), Some(user_org.uuid.clone()));
|
let claims = generate_invite_claims(user.uuid.to_string(), user.email.clone(), org_id.clone(), Some(user_org.uuid.clone()));
|
||||||
let invite_token = encode_jwt(&claims);
|
let invite_token = encode_jwt(&claims);
|
||||||
if let Some(ref mail_config) = CONFIG.mail {
|
if let Some(ref mail_config) = CONFIG.mail {
|
||||||
if let Err(e) = mail::send_invite(&user.email, &org_id, &user_org.uuid, &invite_token, &org_name, mail_config) {
|
mail::send_invite(&user.email, &org_id, &user_org.uuid, &invite_token, &org_name, mail_config)?;
|
||||||
err!(format!("There has been a problem sending the email: {}", e))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -65,7 +65,7 @@ pub fn send_password_hint(address: &str, hint: Option<String>, config: &MailConf
|
||||||
.and(Ok(()))
|
.and(Ok(()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_invite(address: &str, org_id: &str, org_user_id: &str, token: &str, org_name: &str, config: &MailConfig) -> Result<(), String> {
|
pub fn send_invite(address: &str, org_id: &str, org_user_id: &str, token: &str, org_name: &str, config: &MailConfig) -> EmptyResult {
|
||||||
let (subject, body) = {
|
let (subject, body) = {
|
||||||
(format!("Join {}", &org_name),
|
(format!("Join {}", &org_name),
|
||||||
format!(
|
format!(
|
||||||
|
@ -85,10 +85,10 @@ pub fn send_invite(address: &str, org_id: &str, org_user_id: &str, token: &str,
|
||||||
.header(("Content-Type", "text/html"))
|
.header(("Content-Type", "text/html"))
|
||||||
.body(body)
|
.body(body)
|
||||||
.build()
|
.build()
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| Error::new("Error building invite email", e.to_string()))?;
|
||||||
|
|
||||||
mailer(config)
|
mailer(config)
|
||||||
.send(email.into())
|
.send(email.into())
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| Error::new("Error sending invite email", e.to_string()))
|
||||||
.and(Ok(()))
|
.and(Ok(()))
|
||||||
}
|
}
|
Laden …
In neuem Issue referenzieren