resend invitations
This commit is contained in:
@@ -29,6 +29,24 @@ class Admin::InvitationsController < Admin::BaseController
|
||||
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
|
||||
@invitation = User.find(params[:id])
|
||||
|
||||
|
||||
@@ -65,7 +65,8 @@
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
<%= invitation.invited_by&.name || invitation.invited_by&.email || "-" %>
|
||||
</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" %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
+5
-1
@@ -30,7 +30,11 @@ Rails.application.routes.draw do
|
||||
root "dashboard#index"
|
||||
get "dashboard", to: "dashboard#index"
|
||||
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
|
||||
|
||||
resources :entries do
|
||||
|
||||
Reference in New Issue
Block a user