refactor(invitation): rename methods for consistency and enhance invitation deletion logic
This commit is contained in:
		@@ -144,7 +144,7 @@ class Controller extends BaseController
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function revoke_invitation()
 | 
			
		||||
    public function revokeInvitation()
 | 
			
		||||
    {
 | 
			
		||||
        $invitation = TeamInvitation::whereUuid(request()->route('uuid'))->firstOrFail();
 | 
			
		||||
        $user = User::whereEmail($invitation->email)->firstOrFail();
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@
 | 
			
		||||
namespace App\Livewire\Team;
 | 
			
		||||
 | 
			
		||||
use App\Models\TeamInvitation;
 | 
			
		||||
use App\Models\User;
 | 
			
		||||
use Livewire\Component;
 | 
			
		||||
 | 
			
		||||
class Invitations extends Component
 | 
			
		||||
@@ -14,8 +15,15 @@ class Invitations extends Component
 | 
			
		||||
    public function deleteInvitation(int $invitation_id)
 | 
			
		||||
    {
 | 
			
		||||
        try {
 | 
			
		||||
            $initiation_found = TeamInvitation::ownedByCurrentTeam()->findOrFail($invitation_id);
 | 
			
		||||
            $initiation_found->delete();
 | 
			
		||||
            $invitation = TeamInvitation::ownedByCurrentTeam()->findOrFail($invitation_id);
 | 
			
		||||
            $user = User::whereEmail($invitation->email)->firstOrFail();
 | 
			
		||||
            $emailVerified = $user->hasVerifiedEmail();
 | 
			
		||||
            $forcePasswordReset = $user->force_password_reset;
 | 
			
		||||
            if ($emailVerified === false && $forcePasswordReset === true) {
 | 
			
		||||
                $user->delete();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $invitation->delete();
 | 
			
		||||
            $this->refreshInvitations();
 | 
			
		||||
            $this->dispatch('success', 'Invitation revoked.');
 | 
			
		||||
        } catch (\Exception) {
 | 
			
		||||
 
 | 
			
		||||
@@ -29,15 +29,15 @@ class InviteLink extends Component
 | 
			
		||||
 | 
			
		||||
    public function viaEmail()
 | 
			
		||||
    {
 | 
			
		||||
        $this->generate_invite_link(sendEmail: true);
 | 
			
		||||
        $this->generateInviteLink(sendEmail: true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function viaLink()
 | 
			
		||||
    {
 | 
			
		||||
        $this->generate_invite_link(sendEmail: false);
 | 
			
		||||
        $this->generateInviteLink(sendEmail: false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function generate_invite_link(bool $sendEmail = false)
 | 
			
		||||
    private function generateInviteLink(bool $sendEmail = false)
 | 
			
		||||
    {
 | 
			
		||||
        try {
 | 
			
		||||
            $this->validate();
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
<div>
 | 
			
		||||
    <div class="flex items-start gap-2 pb-10">
 | 
			
		||||
        <div>
 | 
			
		||||
            <h1>Tags</h1>
 | 
			
		||||
            <h1 class="pb-2">Tags</h1>
 | 
			
		||||
            <div>Tags help you to perform actions on multiple resources.</div>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
 
 | 
			
		||||
@@ -18,8 +18,8 @@
 | 
			
		||||
                <div class="flex items-center justify-center gap-2 mx-4 text-xs font-bold ">
 | 
			
		||||
                    <x-modal-confirmation title="Confirm User Deletion?" buttonTitle="Delete" isErrorButton
 | 
			
		||||
                        submitAction="delete({{ $user->id }})" :actions="[
 | 
			
		||||
                            'The selected user will be permanently deleted from Coolify and the database.',
 | 
			
		||||
                            'All resources (application, databases, services, configurations, servers, private keys, tags, etc.) related to this user will be deleted from Coolify and from the server (if the server is reachable).',
 | 
			
		||||
                            'The selected user will be permanently deleted from Coolify\'s database.',
 | 
			
		||||
                            'All resources (application, databases, services, configurations, servers, private keys, tags, etc.) related to this user\'s default team will be deleted from Coolify\'s database.',
 | 
			
		||||
                        ]"
 | 
			
		||||
                        confirmationText="{{ $user->name }}"
 | 
			
		||||
                        confirmationLabel="Please confirm the execution of the actions by entering the User Name below"
 | 
			
		||||
 
 | 
			
		||||
@@ -164,7 +164,7 @@ Route::middleware(['auth', 'verified'])->group(function () {
 | 
			
		||||
 | 
			
		||||
    Route::prefix('invitations')->group(function () {
 | 
			
		||||
        Route::get('/{uuid}', [Controller::class, 'acceptInvitation'])->name('team.invitation.accept');
 | 
			
		||||
        Route::get('/{uuid}/revoke', [Controller::class, 'revoke_invitation'])->name('team.invitation.revoke');
 | 
			
		||||
        Route::get('/{uuid}/revoke', [Controller::class, 'revokeInvitation'])->name('team.invitation.revoke');
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    Route::get('/projects', ProjectIndex::class)->name('project.index');
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user