mirror of
				https://github.com/dani-garcia/vaultwarden.git
				synced 2025-10-31 10:18:19 +02:00 
			
		
		
		
	support /users/<uuid>/invite/resend admin api
				
					
				
			This commit is contained in:
		| @@ -53,7 +53,8 @@ pub fn routes() -> Vec<Route> { | |||||||
|         organizations_overview, |         organizations_overview, | ||||||
|         delete_organization, |         delete_organization, | ||||||
|         diagnostics, |         diagnostics, | ||||||
|         get_diagnostics_config |         get_diagnostics_config, | ||||||
|  |         resend_user_invite, | ||||||
|     ] |     ] | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -435,6 +436,19 @@ async fn remove_2fa(uuid: String, _token: AdminToken, mut conn: DbConn) -> Empty | |||||||
|     user.save(&mut conn).await |     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 { | ||||||
|  |         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)] | #[derive(Deserialize, Debug)] | ||||||
| struct UserOrgTypeData { | struct UserOrgTypeData { | ||||||
|     user_type: NumberOrString, |     user_type: NumberOrString, | ||||||
|   | |||||||
							
								
								
									
										21
									
								
								src/static/scripts/admin_users.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								src/static/scripts/admin_users.js
									
									
									
									
										vendored
									
									
								
							| @@ -120,6 +120,24 @@ function inviteUser(event) { | |||||||
|     ); |     ); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | function resendUserInvite (event) { | ||||||
|  |     event.preventDefault(); | ||||||
|  |     event.stopPropagation(); | ||||||
|  |     const id = event.target.parentNode.dataset.vwUserUuid; | ||||||
|  |     const email = event.target.parentNode.dataset.vwUserEmail; | ||||||
|  |     if (!id) { | ||||||
|  |         alert("Required parameters not found!"); | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  |     const confirmed = confirm(`Are you sure you want to resend invitation for "${email}"?`); | ||||||
|  |     if (confirmed) { | ||||||
|  |         _post(`${BASE_URL}/admin/users/${id}/invite/resend`, | ||||||
|  |             "Invite sent successfully", | ||||||
|  |             "Error resend invite" | ||||||
|  |         ); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| const ORG_TYPES = { | const ORG_TYPES = { | ||||||
|     "0": { |     "0": { | ||||||
|         "name": "Owner", |         "name": "Owner", | ||||||
| @@ -228,6 +246,9 @@ function initUserTable() { | |||||||
|     document.querySelectorAll("button[vw-enable-user]").forEach(btn => { |     document.querySelectorAll("button[vw-enable-user]").forEach(btn => { | ||||||
|         btn.addEventListener("click", enableUser); |         btn.addEventListener("click", enableUser); | ||||||
|     }); |     }); | ||||||
|  |     document.querySelectorAll("button[vw-resend-user-invite]").forEach(btn => { | ||||||
|  |         btn.addEventListener("click", resendUserInvite); | ||||||
|  |     }); | ||||||
|  |  | ||||||
|     if (jdenticon) { |     if (jdenticon) { | ||||||
|         jdenticon(); |         jdenticon(); | ||||||
|   | |||||||
| @@ -72,6 +72,9 @@ | |||||||
|                                 {{else}} |                                 {{else}} | ||||||
|                                 <button type="button" class="btn btn-sm btn-link p-0 border-0 float-right" vw-enable-user>Enable User</button><br> |                                 <button type="button" class="btn btn-sm btn-link p-0 border-0 float-right" vw-enable-user>Enable User</button><br> | ||||||
|                                 {{/if}} |                                 {{/if}} | ||||||
|  |                                 {{#case _Status 1}} | ||||||
|  |                                 <button type="button" class="btn btn-sm btn-link p-0 border-0 float-right" vw-resend-user-invite>Resend invite</button><br> | ||||||
|  |                                 {{/case}} | ||||||
|                             </span> |                             </span> | ||||||
|                         </td> |                         </td> | ||||||
|                     </tr> |                     </tr> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user