resend invitations

This commit is contained in:
2026-01-29 15:47:03 +01:00
parent 887d52c447
commit e7f2215be4
3 changed files with 25 additions and 2 deletions
@@ -29,6 +29,24 @@ class Admin::InvitationsController < Admin::BaseController
end end
end end
def resend
@invitation = User.find(params[:id])
if @invitation.invitation_accepted_at.present?
redirect_to admin_invitations_path, alert: "Cannot resend an accepted invitation."
return
end
@invitation.update!(
invitation_token: SecureRandom.urlsafe_base64(32),
invitation_sent_at: Time.current
)
InvitationMailer.invite(@invitation).deliver_later
redirect_to admin_invitations_path, notice: "Invitation resent to #{@invitation.email}"
end
def destroy def destroy
@invitation = User.find(params[:id]) @invitation = User.find(params[:id])
+2 -1
View File
@@ -65,7 +65,8 @@
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"> <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<%= invitation.invited_by&.name || invitation.invited_by&.email || "-" %> <%= invitation.invited_by&.name || invitation.invited_by&.email || "-" %>
</td> </td>
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium"> <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium space-x-4">
<%= button_to "Re-send", resend_admin_invitation_path(invitation), method: :put, class: "text-blue-600 hover:text-blue-900" %>
<%= button_to "Cancel", admin_invitation_path(invitation), method: :delete, data: { turbo_confirm: "Are you sure you want to cancel this invitation?" }, class: "text-red-600 hover:text-red-900" %> <%= button_to "Cancel", admin_invitation_path(invitation), method: :delete, data: { turbo_confirm: "Are you sure you want to cancel this invitation?" }, class: "text-red-600 hover:text-red-900" %>
</td> </td>
</tr> </tr>
+5 -1
View File
@@ -30,7 +30,11 @@ Rails.application.routes.draw do
root "dashboard#index" root "dashboard#index"
get "dashboard", to: "dashboard#index" get "dashboard", to: "dashboard#index"
resources :users, only: [ :index, :edit, :update, :destroy ] resources :users, only: [ :index, :edit, :update, :destroy ]
resources :invitations, only: [ :index, :new, :create, :destroy ] resources :invitations, only: [ :index, :new, :create, :destroy ] do
member do
put :resend
end
end
end end
resources :entries do resources :entries do