diff --git a/app/Livewire/ManageUsers.php b/app/Livewire/ManageUsers.php index 9eaaecd..cb58ae0 100644 --- a/app/Livewire/ManageUsers.php +++ b/app/Livewire/ManageUsers.php @@ -45,11 +45,12 @@ class ManageUsers extends Component Flux::modal('invite-user')->close(); // Refresh the data - $this->invitations = Invitation::all(); + $this->invitations->prepend($inv); + $this->reset(['invite_email', 'send_email']); $this->invite_email = ''; $this->send_email = false; - session()->flash('success', 'Invitation created successfully' . ($emailSent ? ' and email sent' : '') . '.'); + session()->flash('success', 'Invitation created successfully' . ($this->send_email ? ' and email sent' : '') . '.'); } public function deleteUser(User $user) @@ -81,6 +82,24 @@ class ManageUsers extends Component session()->flash('success', "User role updated to {$role}."); } + public function deleteInvitation(Invitation $invitation) + { + $this->authorize('invite', User::class); + + // Only allow deletion of pending invitations + if (!$invitation->isPending()) { + session()->flash('error', 'Cannot delete accepted invitations.'); + return; + } + + $invitation->delete(); + + // Refresh the data + $this->invitations = Invitation::orderBy('accepted_at', 'desc')->get(); + + session()->flash('success', 'Invitation deleted successfully.'); + } + public function render() { return view('livewire.manage-users'); diff --git a/app/Models/Invitation.php b/app/Models/Invitation.php index 9c2957f..8f1f21a 100644 --- a/app/Models/Invitation.php +++ b/app/Models/Invitation.php @@ -3,6 +3,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; class Invitation extends Model { @@ -28,6 +29,11 @@ class Invitation extends Model $this->save(); } + public function creator(): BelongsTo + { + return $this->belongsTo(User::class, 'invited_by', 'id'); + } + public function getInviteUrl(): string { return route('register', ['code' => $this->code]); diff --git a/resources/views/emails/invitation.blade.php b/resources/views/emails/invitation.blade.php index 7868c6a..35edb0c 100644 --- a/resources/views/emails/invitation.blade.php +++ b/resources/views/emails/invitation.blade.php @@ -1,5 +1,6 @@ + @@ -13,6 +14,7 @@ margin: 0; padding: 20px; } + .container { max-width: 600px; margin: 0 auto; @@ -21,20 +23,24 @@ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); overflow: hidden; } + .header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 30px 20px; text-align: center; } + .header h1 { margin: 0; font-size: 28px; font-weight: 600; } + .content { padding: 30px 20px; } + .button { display: inline-block; background: #667eea; @@ -45,9 +51,11 @@ font-weight: 500; margin: 20px 0; } + .button:hover { background: #5a6fd8; } + .footer { background: #f8f9fa; padding: 20px; @@ -55,6 +63,7 @@ color: #6c757d; font-size: 14px; } + .invite-details { background: #f8f9fa; border-radius: 6px; @@ -63,43 +72,48 @@ } +

= AuthentiKate

You've been invited to join our authentication platform

- +

Hello!

- -

You've been invited to create an account on AuthentiKate, our secure authentication platform. This will give you access to various applications and services.

- + +

You've been invited to create an account on AuthentiKate, our secure authentication + platform. This will give you access to various applications and services.

+

Invitation Details:

Email: {{ $invitation->email }}

-

Invited by: Admin

+

Invited by: {{ $invitation->creator->name }}

Expires: {{ $invitation->expires_at->format('F j, Y \a\t g:i A') }}

- +

To accept this invitation and create your account, click the button below:

- +
Accept Invitation
- +

Or copy and paste this link into your browser:

-

+

{{ $invitation->getInviteUrl() }}

- -

Note: This invitation will expire on {{ $invitation->expires_at->format('F j, Y') }}. If you don't create your account by then, you'll need to request a new invitation.

+ +

Note: This invitation will expire on {{ $invitation->expires_at->format('F j, Y') }}. If + you don't create your account by then, you'll need to request a new invitation.

- +
+ \ No newline at end of file diff --git a/resources/views/livewire/manage-users.blade.php b/resources/views/livewire/manage-users.blade.php index d8b3eee..0d7cf56 100644 --- a/resources/views/livewire/manage-users.blade.php +++ b/resources/views/livewire/manage-users.blade.php @@ -67,8 +67,11 @@ {{$inv->status}} @endswitch -
+
Copy invite link + @if($inv->isPending()) + + @endif
@endforeach