mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-07-17 17:51:11 +00:00
Merge pull request #3397 from nikolaevn/feature/add-admin-reinvite-endpoint
support `/users/<uuid>/invite/resend` admin api
This commit is contained in:
commit
d1ecf03f44
3 changed files with 44 additions and 1 deletions
|
@ -53,7 +53,8 @@ pub fn routes() -> Vec<Route> {
|
|||
organizations_overview,
|
||||
delete_organization,
|
||||
diagnostics,
|
||||
get_diagnostics_config
|
||||
get_diagnostics_config,
|
||||
resend_user_invite,
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -435,6 +436,24 @@ async fn remove_2fa(uuid: String, _token: AdminToken, mut conn: DbConn) -> Empty
|
|||
user.save(&mut conn).await
|
||||
}
|
||||
|
||||
#[post("/users/<uuid>/invite/resend")]
|
||||
async fn resend_user_invite(uuid: String, _token: AdminToken, mut conn: DbConn) -> EmptyResult {
|
||||
if let Some(user) = User::find_by_uuid(&uuid, &mut conn).await {
|
||||
//TODO: replace this with user.status check when it will be available (PR#3397)
|
||||
if !user.password_hash.is_empty() {
|
||||
err_code!("User already accepted invitation", Status::BadRequest.code);
|
||||
}
|
||||
|
||||
if CONFIG.mail_enabled() {
|
||||
mail::send_invite(&user.email, &user.uuid, None, None, &CONFIG.invitation_org_name(), None).await
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
} else {
|
||||
err_code!("User doesn't exist", Status::NotFound.code);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
struct UserOrgTypeData {
|
||||
user_type: NumberOrString,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue