Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

updates

Andras Bacsaia97d22b81b44
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index 63d24a219a..2116c99223 100644
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -2,9 +2,12 @@
namespace App\Http\Controllers;
+use App\Http\Livewire\Team\Invitations;
use App\Models\InstanceSettings;
use App\Models\Project;
use App\Models\Server;
+use App\Models\TeamInvitation;
+use App\Models\User;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
@@ -53,14 +56,56 @@ class Controller extends BaseController
}
public function team()
{
- ray(auth()->user()->isAdmin());
$invitations = [];
if (auth()->user()->isAdmin()) {
- $invitations = auth()->user()->currentTeam()->invitations;
+ $invitations = TeamInvitation::whereTeamId(auth()->user()->currentTeam()->id)->get();
}
return view('team.show', [
- 'transactional_emails_active' => data_get(InstanceSettings::get(), 'extra_attributes.smtp_host') ? true : false,
+ 'transactional_emails_active' => is_transactional_emails_active(),
'invitations' => $invitations,
]);
}
+ public function accept_invitation()
+ {
+ try {
+ $invitation = TeamInvitation::whereUuid(request()->route('uuid'))->firstOrFail();
+ $user = User::whereEmail($invitation->email)->firstOrFail();
+ if (is_null(auth()->user())) {
+ return redirect()->route('login');
+ }
+ if (auth()->user()->id !== $user->id) {
+ abort(401);
+ }
+
+ $created_at = $invitation->created_at;
+ $diff = $created_at->diffInMinutes(now());
+ if ($diff <= config('constants.invitation.link.expiration')) {
+ $user->teams()->attach($invitation->team->id, ['role' => $invitation->role]);
+ $invitation->delete();
+ return redirect()->route('team.show');
+ } else {
+ $invitation->delete();
+ abort(401);
+ }
+ } catch (\Throwable $th) {
+ throw $th;
+ }
+ }
+ public function revoke_invitation()
+ {
+ try {
+ $invitation = TeamInvitation::whereUuid(request()->route('uuid'))->firstOrFail();
+ $user = User::whereEmail($invitation->email)->firstOrFail();
+ if (is_null(auth()->user())) {
+ return redirect()->route('login');
+ }
+ if (auth()->user()->id !== $user->id) {
+ abort(401);
+ }
+ $invitation->delete();
+ return redirect()->route('team.show');
+ } catch (\Throwable $th) {
+ throw $th;
+ }
+ }
}
diff --git a/app/Http/Livewire/Settings/Email.php b/app/Http/Livewire/Settings/Email.php
index 42a1c70004..311e244053 100644
--- a/app/Http/Livewire/Settings/Email.php
+++ b/app/Http/Livewire/Settings/Email.php
@@ -2,10 +2,8 @@
namespace App\Http\Livewire\Settings;
-use App\Mail\TestTransactionalEmail;
use App\Models\InstanceSettings;
-use App\Notifications\TestTransactionEmail;
-use Illuminate\Support\Facades\Mail;
+use App\Notifications\TransactionalEmails\TestEmail;
use Illuminate\Support\Facades\Notification;
use Livewire\Component;
@@ -20,46 +18,17 @@ class Email extends Component
'settings.extra_attributes.smtp_username' => 'nullable',
'settings.extra_attributes.smtp_password' => 'nullable',
'settings.extra_attributes.smtp_timeout' => 'nullable',
- 'settings.extra_attributes.smtp_recipients' => 'required',
'settings.extra_attributes.smtp_test_recipients' => 'nullable',
'settings.extra_attributes.smtp_from_address' => 'required|email',
'settings.extra_attributes.smtp_from_name' => 'required',
];
public function test_email()
{
- Notification::send($this->settings, new TestTransactionEmail);
+ Notification::send($this->settings, new TestEmail);
}
- // public function test_email()
- // {
- // config()->set('mail.default', 'smtp');
- // config()->set('mail.mailers.smtp', [
- // "transport" => "smtp",
- // "host" => $this->settings->smtp_host,
- // "port" => $this->settings->smtp_port,
- // "encryption" => $this->settings->smtp_encryption,
- // "username" => $this->settings->smtp_username,
- // "password" => $this->settings->smtp_password,
- // ]);
-
- // $this->send_email();
- // }
- // public function test_email_local()
- // {
- // config()->set('mail.default', 'smtp');
- // config()->set('mail.mailers.smtp', [
- // "transport" => "smtp",
- // "host" => 'coolify-mail',
- // "port" => 1025,
- // ]);
- // $this->send_email();
- // }
- // private function send_email()
- // {
- // }
public function submit()
{
$this->validate();
- $this->settings->extra_attributes->smtp_recipients = str_replace(' ', '', $this->settings->extra_attributes->smtp_recipients);
$this->settings->extra_attributes->smtp_test_recipients = str_replace(' ', '', $this->settings->extra_attributes->smtp_test_recipients);
$this->settings->save();
}
diff --git a/app/Http/Livewire/Team/Invitations.php b/app/Http/Livewire/Team/Invitations.php
new file mode 100644
index 0000000000..e61aca0e70
--- /dev/null
+++ b/app/Http/Livewire/Team/Invitations.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Http\Livewire\Team;
+
+use App\Models\TeamInvitation;
+use Livewire\Component;
+
+class Invitations extends Component
+{
+ public $invitations;
+ protected $listeners = ['refreshInvitations'];
+ public function refreshInvitations()
+ {
+ $this->invitations = TeamInvitation::whereTeamId(auth()->user()->currentTeam()->id)->get();
+ }
+ public function deleteInvitation(int $invitation_id)
+ {
+ TeamInvitation::find($invitation_id)->delete();
+ $this->refreshInvitations();
+ }
+}
diff --git a/app/Http/Livewire/Team/InviteLink.php b/app/Http/Livewire/Team/InviteLink.php
index 04159fc15e..a557ea3d54 100644
--- a/app/Http/Livewire/Team/InviteLink.php
+++ b/app/Http/Livewire/Team/InviteLink.php
@@ -4,42 +4,64 @@ namespace App\Http\Livewire\Team;
use App\Models\TeamInvitation;
use App\Models\User;
+use App\Notifications\TransactionalEmails\InvitationLinkEmail;
use Livewire\Component;
use Visus\Cuid2\Cuid2;
class InviteLink extends Component
{
public string $email;
+ public string $role = 'member';
public function mount()
{
- $this->email = config('app.env') === 'local' ? '[email protected]' : '';
+ $this->email = config('app.env') === 'local' ? '[email protected]' : '';
}
- public function inviteByLink()
+ public function viaEmail()
+ {
+ $this->generate_invite_link(isEmail: true);
+ }
+ private function generate_invite_link(bool $isEmail = false)
{
- $uuid = new Cuid2(32);
- $link = url('/') . '/api/invitation/' . $uuid;
try {
- $user_exists = User::whereEmail($this->email)->exists();
- if (!$user_exists) {
+ $uuid = new Cuid2(32);
+ $link = url('/') . config('constants.invitation.link.base_url') . $uuid;
+
+ $user = User::whereEmail($this->email);
+
+ if (!$user->exists()) {
return general_error_handler(that: $this, customErrorMessage: "$this->email must be registered first (or activate transactional emails to invite via email).");
}
- $invitation = TeamInvitation::where('email', $this->email);
+
+ $member_emails = session('currentTeam')->members()->get()->pluck('email');
+ if ($member_emails->contains($this->email)) {
+ return general_error_handler(that: $this, customErrorMessage: "$this->email is already a member of " . session('currentTeam')->name . ".");
+ }
+
+ $invitation = TeamInvitation::whereEmail($this->email);
+
if ($invitation->exists()) {
$created_at = $invitation->first()->created_at;
$diff = $created_at->diffInMinutes(now());
- if ($diff < 11) {
- return general_error_handler(that: $this, customErrorMessage: "Invitation already sent and active for $this->email.");
+ if ($diff <= config('constants.invitation.link.expiration')) {
+ return general_error_handler(that: $this, customErrorMessage: "Invitation already sent to $this->email and waiting for action.");
} else {
$invitation->delete();
}
}
- $invitation = TeamInvitation::firstOrCreate([
+
+ TeamInvitation::firstOrCreate([
'team_id' => session('currentTeam')->id,
+ 'uuid' => $uuid,
'email' => $this->email,
- 'role' => 'readonly',
+ 'role' => $this->role,
'link' => $link,
+ 'via' => $isEmail ? 'email' : 'link',
]);
- $this->emit('reloadWindow');
+ if ($isEmail) {
+ $user->first()->notify(new InvitationLinkEmail());
+ }
+ $this->emit('refreshInvitations');
+ $this->emit('message', 'Invitation sent successfully.');
} catch (\Throwable $e) {
$error_message = $e->getMessage();
if ($e->getCode() === '23505') {
@@ -48,4 +70,8 @@ class InviteLink extends Component
return general_error_handler(err: $e, that: $this, customErrorMessage: $error_message);
}
}
+ public function inviteByLink()
+ {
+ $this->generate_invite_link();
+ }
}
diff --git a/app/Http/Livewire/Team/Member.php b/app/Http/Livewire/Team/Member.php
index 65cca30380..5f037e4441 100644
--- a/app/Http/Livewire/Team/Member.php
+++ b/app/Http/Livewire/Team/Member.php
@@ -15,7 +15,7 @@ class Member extends Component
}
public function makeReadonly()
{
- $this->member->teams()->updateExistingPivot(session('currentTeam')->id, ['role' => 'readonly']);
+ $this->member->teams()->updateExistingPivot(session('currentTeam')->id, ['role' => 'member']);
$this->emit('reloadWindow');
}
public function remove()
diff --git a/app/Models/InstanceSettings.php b/app/Models/InstanceSettings.php
index 9a3ba1a753..cc66facd48 100644
--- a/app/Models/InstanceSettings.php
+++ b/app/Models/InstanceSettings.php
@@ -18,7 +18,7 @@ class InstanceSettings extends Model implements SendsEmail
{
return $this->extra_attributes->modelScope();
}
- public function routeNotificationForEmail(string $attribute = 'smtp_recipients')
+ public function routeNotificationForEmail(string $attribute = 'smtp_test_recipients')
{
$recipients = $this->extra_attributes->get($attribute, '');
if (is_null($recipients) || $recipients === '') {
diff --git a/app/Models/TeamInvitation.php b/app/Models/TeamInvitation.php
index 91ad9837ac..c326d7d403 100644
--- a/app/Models/TeamInvitation.php
+++ b/app/Models/TeamInvitation.php
@@ -8,9 +8,11 @@ class TeamInvitation extends Model
{
protected $fillable = [
'team_id',
+ 'uuid',
'email',
'role',
'link',
+ 'via',
];
public function team()
{
diff --git a/app/Models/User.php b/app/Models/User.php
index 9f64bcd5c6..a043ae89d1 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use App\Notifications\Channels\SendsEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;
@@ -10,7 +11,7 @@ use Laravel\Sanctum\HasApiTokens;
use Visus\Cuid2\Cuid2;
use Laravel\Fortify\TwoFactorAuthenticatable;
-class User extends Authenticatable
+class User extends Authenticatable implements SendsEmail
{
use HasApiTokens, HasFactory, Notifiable, TwoFactorAuthenticatable;
protected $fillable = [
@@ -46,10 +47,13 @@ class User extends Authenticatable
$user->teams()->attach($new_team, ['role' => 'owner']);
});
}
+ public function routeNotificationForEmail()
+ {
+ return $this->email;
+ }
public function isAdmin()
{
if (auth()->user()->id === 0) {
- ray('is root user');
return true;
}
$teams = $this->teams()->get();
@@ -59,7 +63,6 @@ class User extends Authenticatable
($is_part_of_root_team->pivot->role === 'admin' || $is_part_of_root_team->pivot->role === 'owner');
if ($is_part_of_root_team && $is_admin_of_root_team) {
- ray('is admin of root team');
return true;
}
$role = $teams->where('id', session('currentTeam')->id)->first()->pivot->role;
diff --git a/app/Notifications/Channels/EmailChannel.php b/app/Notifications/Channels/EmailChannel.php
index c4e8eeccdc..b2da2bb24a 100644
--- a/app/Notifications/Channels/EmailChannel.php
+++ b/app/Notifications/Channels/EmailChannel.php
@@ -12,11 +12,10 @@ class EmailChannel
{
$this->bootConfigs($notifiable);
- if ($notification instanceof \App\Notifications\TestNotification) {
+ $is_test_notification = $notification instanceof \App\Notifications\TestNotification;
+
+ if ($is_test_notification) {
$bcc = $notifiable->routeNotificationForEmail('smtp_test_recipients');
- if (count($bcc) === 0) {
- $bcc = $notifiable->routeNotificationForEmail();
- }
} else {
$bcc = $notifiable->routeNotificationForEmail();
}
diff --git a/app/Notifications/Channels/TransactionalEmailChannel.php b/app/Notifications/Channels/TransactionalEmailChannel.php
new file mode 100644
index 0000000000..1fb3f19719
--- /dev/null
+++ b/app/Notifications/Channels/TransactionalEmailChannel.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace App\Notifications\Channels;
+
+use App\Models\InstanceSettings;
+use App\Models\User;
+use Illuminate\Mail\Message;
+use Illuminate\Notifications\Notification;
+use Illuminate\Support\Facades\Mail;
+
+class TransactionalEmailChannel
+{
+ public function send(User $notifiable, Notification $notification): void
+ {
+ $email = $notifiable->email;
+ if (!$email) {
+ return;
+ }
+ $settings = InstanceSettings::get();
+ $this->bootConfigs($settings);
+ $mailMessage = $notification->toMail($notifiable);
+
+ Mail::send(
+ [],
+ [],
+ fn (Message $message) => $message
+ ->from(
+ $settings->extra_attributes?->get('smtp_from_address'),
+ $settings->extra_attributes?->get('smtp_from_name')
+ )
+ ->to($email)
+ ->subject($mailMessage->subject)
+ ->html((string)$mailMessage->render())
+ );
+ }
+
+ private function bootConfigs(InstanceSettings $settings): void
+ {
+ config()->set('mail.default', 'smtp');
+ config()->set('mail.mailers.smtp', [
+ "transport" => "smtp",
+ "host" => $settings->extra_attributes?->get('smtp_host'),
+ "port" => $settings->extra_attributes?->get('smtp_port'),
+ "encryption" => $settings->extra_attributes?->get('smtp_encryption'),
+ "username" => $settings->extra_attributes?->get('smtp_username'),
+ "password" => $settings->extra_attributes?->get('smtp_password'),
+ "timeout" => $settings->extra_attributes?->get('smtp_timeout'),
+ "local_domain" => null,
+ ]);
+ }
+}
diff --git a/app/Notifications/TestNotification.php b/app/Notifications/TestNotification.php
index d388635e76..bc207be88d 100644
--- a/app/Notifications/TestNotification.php
+++ b/app/Notifications/TestNotification.php
@@ -12,20 +12,6 @@ use Illuminate\Notifications\Notification;
class TestNotification extends Notification implements ShouldQueue
{
use Queueable;
-
- /**
- * Create a new notification instance.
- */
- public function __construct()
- {
- //
- }
-
- /**
- * Get the notification's delivery channels.
- *
- * @return array<int, string>
- */
public function via(object $notifiable): array
{
$channels = [];
@@ -33,11 +19,7 @@ class TestNotification extends Notification implements ShouldQueue
$notifiable->extra_attributes?->get('discord_active') && $channels[] = DiscordChannel::class;
return $channels;
}
-
- /**
- * Get the mail representation of the notification.
- */
- public function toMail(object $notifiable): MailMessage
+ public function toMail(): MailMessage
{
return (new MailMessage)
->subject('Coolify Test Notification')
@@ -45,20 +27,8 @@ class TestNotification extends Notification implements ShouldQueue
->line('You have successfully received a test Email notification from Coolify. 🥳');
}
- public function toDiscord(object $notifiable): string
+ public function toDiscord(): string
{
return 'You have successfully received a test Discord notification from Coolify. 🥳 [Go to your dashboard](' . url('/') . ')';
}
-
- /**
- * Get the array representation of the notification.
- *
- * @return array<string, mixed>
- */
- public function toArray(object $notifiable): array
- {
- return [
- //
- ];
- }
}
diff --git a/app/Notifications/TestTransactionEmail.php b/app/Notifications/TestTransactionEmail.php
deleted file mode 100644
index 685cbea7d3..0000000000
--- a/app/Notifications/TestTransactionEmail.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-
-namespace App\Notifications;
-
-use App\Notifications\Channels\EmailChannel;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Notifications\Messages\MailMessage;
-use Illuminate\Notifications\Notification;
-
-class TestTransactionEmail extends Notification implements ShouldQueue
-{
- use Queueable;
-
- /**
- * Create a new notification instance.
- */
- public function __construct()
- {
- //
- }
-
- /**
- * Get the notification's delivery channels.
- *
- * @return array<int, string>
- */
- public function via(object $notifiable): array
- {
- $channels = [];
- $notifiable->extra_attributes?->get('smtp_host') && $channels[] = EmailChannel::class;
- return $channels;
- }
-
- /**
- * Get the mail representation of the notification.
- */
- public function toMail(object $notifiable): MailMessage
- {
- $mail = new MailMessage();
- $mail->subject('Coolify Test Notification');
- $mail->view('emails.test-email');
- return $mail;
- }
-
- public function toArray(object $notifiable): array
- {
- return [
- //
- ];
- }
-}
diff --git a/app/Notifications/TransactionalEmails/InvitationLinkEmail.php b/app/Notifications/TransactionalEmails/InvitationLinkEmail.php
new file mode 100644
index 0000000000..fe53c6fce7
--- /dev/null
+++ b/app/Notifications/TransactionalEmails/InvitationLinkEmail.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace App\Notifications\TransactionalEmails;
+
+use App\Models\Team;
+use App\Models\TeamInvitation;
+use App\Models\User;
+use App\Notifications\Channels\TransactionalEmailChannel;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Notifications\Messages\MailMessage;
+use Illuminate\Notifications\Notification;
+
+class InvitationLinkEmail extends Notification implements ShouldQueue
+{
+ use Queueable;
+ public function via()
+ {
+ return [TransactionalEmailChannel::class];
+ }
+
+ public function toMail(User $user): MailMessage
+ {
+ $invitation = TeamInvitation::whereEmail($user->email)->first();
+ $invitation_team = Team::find($invitation->team->id);
+
+ $mail = new MailMessage();
+ $mail->subject('Invitation for ' . $invitation_team->name);
+ $mail->view('emails.invitation-link', [
+ 'team' => $invitation_team->name,
+ 'email' => $user->email,
+ 'invitation_link' => $invitation->link,
+ ]);
+ return $mail;
+ }
+}
diff --git a/app/Notifications/TransactionalEmails/TestEmail.php b/app/Notifications/TransactionalEmails/TestEmail.php
new file mode 100644
index 0000000000..19e45dfc23
--- /dev/null
+++ b/app/Notifications/TransactionalEmails/TestEmail.php
@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Notifications\TransactionalEmails;
+
+use App\Notifications\Channels\EmailChannel;
+use App\Notifications\Channels\TransactionalEmailChannel;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Notifications\Messages\MailMessage;
+use Illuminate\Notifications\Notification;
+
+class TestEmail extends Notification implements ShouldQueue
+{
+ use Queueable;
+ public function via(): array
+ {
+ return [EmailChannel::class];
+ }
+ public function toMail(): MailMessage
+ {
+ $mail = new MailMessage();
+ $mail->subject('Coolify Test Notification');
+ $mail->view('emails.test');
+ return $mail;
+ }
+}
diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php
index 8a7a99af81..d5259ae945 100644
--- a/bootstrap/helpers/shared.php
+++ b/bootstrap/helpers/shared.php
@@ -1,5 +1,6 @@
<?php
+use App\Models\InstanceSettings;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Route;
@@ -59,3 +60,8 @@ function generate_application_name(string $git_repository, string $git_branch)
$cuid = new Cuid2(7);
return Str::kebab("{$git_repository}:{$git_branch}-{$cuid}");
}
+
+function is_transactional_emails_active()
+{
+ return data_get(InstanceSettings::get(), 'extra_attributes.smtp_host');
+}
diff --git a/config/constants.php b/config/constants.php
new file mode 100644
index 0000000000..a3c88c8e82
--- /dev/null
+++ b/config/constants.php
@@ -0,0 +1,9 @@
+<?php
+return [
+ 'invitation' => [
+ 'link' => [
+ 'base_url' => '/invitations/',
+ 'expiration' => 10,
+ ],
+ ],
+];
diff --git a/database/migrations/2023_03_20_112812_create_team_user_table.php b/database/migrations/2023_03_20_112812_create_team_user_table.php
index e794dc645f..9eeeb4b31b 100644
--- a/database/migrations/2023_03_20_112812_create_team_user_table.php
+++ b/database/migrations/2023_03_20_112812_create_team_user_table.php
@@ -15,7 +15,7 @@ return new class extends Migration
$table->id();
$table->foreignId('team_id');
$table->foreignId('user_id');
- $table->string('role')->default('readonly');
+ $table->string('role')->default('member');
$table->timestamps();
$table->unique(['team_id', 'user_id']);
diff --git a/database/migrations/2023_03_20_112813_create_team_invitations_table.php b/database/migrations/2023_03_20_112813_create_team_invitations_table.php
index 55be413028..9bce2be922 100644
--- a/database/migrations/2023_03_20_112813_create_team_invitations_table.php
+++ b/database/migrations/2023_03_20_112813_create_team_invitations_table.php
@@ -13,10 +13,12 @@ return new class extends Migration
{
Schema::create('team_invitations', function (Blueprint $table) {
$table->id();
+ $table->string('uuid')->unique();
$table->foreignId('team_id')->constrained()->cascadeOnDelete();
$table->string('email');
- $table->string('role')->default('readonly');
- $table->string('link')->nullable();
+ $table->string('role')->default('member');
+ $table->string('link');
+ $table->string('via')->default('link');
$table->timestamps();
$table->unique(['team_id', 'email']);
diff --git a/database/seeders/InstanceSettingsSeeder.php b/database/seeders/InstanceSettingsSeeder.php
index d9356d0112..2e7c166d60 100644
--- a/database/seeders/InstanceSettingsSeeder.php
+++ b/database/seeders/InstanceSettingsSeeder.php
@@ -16,7 +16,7 @@ class InstanceSettingsSeeder extends Seeder
'id' => 0,
'is_registration_enabled' => true,
'extra_attributes' => [
- 'smtp_recipients' => '[email protected],[email protected]',
+ 'smtp_test_recipients' => '[email protected],[email protected]',
'smtp_host' => 'coolify-mail',
'smtp_port' => 1025,
'smtp_from_address' => '[email protected]',
diff --git a/resources/views/components/applications/navbar.blade.php b/resources/views/components/applications/navbar.blade.php
index 4669196151..6a5fa26659 100644
--- a/resources/views/components/applications/navbar.blade.php
+++ b/resources/views/components/applications/navbar.blade.php
@@ -1,4 +1,4 @@
-<nav class="flex items-center gap-4 py-2 border-b-2 border-solid border-coolgray-200">
+<nav class="flex items-end gap-4 py-2 border-b-2 border-solid border-coolgray-200">
<a class="{{ request()->routeIs('project.application.configuration') ? 'text-white' : '' }}"
href="{{ route('project.application.configuration', [
'project_uuid' => Route::current()->parameters()['project_uuid'],
diff --git a/resources/views/components/forms/select.blade.php b/resources/views/components/forms/select.blade.php
index 49ee88f79c..eff30be75a 100644
--- a/resources/views/components/forms/select.blade.php
+++ b/resources/views/components/forms/select.blade.php
@@ -6,33 +6,33 @@
])
<div {{ $attributes->merge(['class' => 'flex flex-col']) }}>
- <label class="label" for={{ $id }}>
- <span class="label-text">
- @if ($label)
+ @if ($label)
+ <label class="label" for={{ $id }}>
+ <span class="label-text">
{{ $label }}
- @endif
- @if ($required)
- <span class="text-warning">*</span>
- @endif
- @if ($helper)
- <div class="group">
- <div class="cursor-pointer text-warning">
- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
- class="w-4 h-4 stroke-current">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
- d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
- </svg>
- </div>
- <div class="absolute hidden text-xs group-hover:block border-coolgray-400 bg-coolgray-500">
- <div class="p-4 card-body">
- {!! $helper !!}
+ @if ($required)
+ <span class="text-warning">*</span>
+ @endif
+ @if ($helper)
+ <div class="group">
+ <div class="cursor-pointer text-warning">
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
+ class="w-4 h-4 stroke-current">
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
+ d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
+ </svg>
+ </div>
+ <div class="absolute hidden text-xs group-hover:block border-coolgray-400 bg-coolgray-500">
+ <div class="p-4 card-body">
+ {!! $helper !!}
+ </div>
</div>
</div>
- </div>
- @endif
- </span>
- </label>
- <select {{ $attributes }}
+ @endif
+ </span>
+ </label>
+ @endif
+ <select class="select-xs h-7" {{ $attributes }}
@if ($id) name={{ $id }} wire:model.defer={{ $id }} @endif>
{{ $slot }}
</select>
diff --git a/resources/views/components/layout.blade.php b/resources/views/components/layout.blade.php
index f89c49e631..cff9a80b18 100644
--- a/resources/views/components/layout.blade.php
+++ b/resources/views/components/layout.blade.php
@@ -38,6 +38,10 @@
<x-version class="fixed left-2 bottom-1" />
@auth
<script>
+ function copyToClipboard(text) {
+ navigator.clipboard.writeText(text);
+ Livewire.emit('message', 'Copied to clipboard.');
+ }
Livewire.on('reloadWindow', () => {
window.location.reload();
})
@@ -45,6 +49,10 @@
console.log(message);
alert(message);
})
+ Livewire.on('message', (message) => {
+ console.log(message);
+ alert(message);
+ })
Livewire.on('saved', (message) => {
if (message) console.log(message);
else console.log('saved');
diff --git a/resources/views/components/server/navbar.blade.php b/resources/views/components/server/navbar.blade.php
index 94e320a1ef..3f2bc7e0b9 100644
--- a/resources/views/components/server/navbar.blade.php
+++ b/resources/views/components/server/navbar.blade.php
@@ -1,7 +1,7 @@
<div class="pb-6">
<h1>Server</h1>
<div class="pt-2 pb-10 text-sm">{{ data_get($server, 'name') }}</div>
- <nav class="flex items-center gap-4 py-2 border-b-2 border-solid border-coolgray-200">
+ <nav class="flex items-end gap-4 py-2 border-b-2 border-solid border-coolgray-200">
<a class="{{ request()->routeIs('server.show') ? 'text-white' : '' }}"
href="{{ route('server.show', [
'server_uuid' => Route::current()->parameters()['server_uuid'],
diff --git a/resources/views/components/settings/navbar.blade.php b/resources/views/components/settings/navbar.blade.php
index 65babd276a..bce6bcb16b 100644
--- a/resources/views/components/settings/navbar.blade.php
+++ b/resources/views/components/settings/navbar.blade.php
@@ -1,7 +1,7 @@
<div class="pb-6">
<h1>Settings</h1>
<div class="pt-2 pb-10 text-sm">Instance wide settings for Coolify.</div>
- <nav class="flex items-center gap-4 py-2 border-b-2 border-solid border-coolgray-200">
+ <nav class="flex items-end gap-4 py-2 border-b-2 border-solid border-coolgray-200">
<a class="{{ request()->routeIs('settings.configuration') ? 'text-white' : '' }}"
href="{{ route('settings.configuration') }}">
<button>Configuration</button>
diff --git a/resources/views/components/team/navbar.blade.php b/resources/views/components/team/navbar.blade.php
index 918551887f..50d0dd99e4 100644
--- a/resources/views/components/team/navbar.blade.php
+++ b/resources/views/components/team/navbar.blade.php
@@ -18,7 +18,7 @@
</li>
</ol>
</nav>
- <nav class="flex items-center gap-4 py-2 border-b-2 border-solid border-coolgray-200">
+ <nav class="flex items-end gap-4 py-2 border-b-2 border-solid border-coolgray-200">
<a class="{{ request()->routeIs('team.show') ? 'text-white' : '' }}" href="{{ route('team.show') }}">
<button>Members</button>
</a>
diff --git a/resources/views/emails/invitation-link.blade.php b/resources/views/emails/invitation-link.blade.php
new file mode 100644
index 0000000000..7cdf02259d
--- /dev/null
+++ b/resources/views/emails/invitation-link.blade.php
@@ -0,0 +1,12 @@
+Hello,<br><br>
+
+You have been invited to "{{ $team }}" on "{{ config('app.name') }}".<br><br>
+
+Please click here to accept the invitation: <a href="{{ $invitation_link }}">Accept Invitation</a><br><br>
+
+If you have any questions, please contact the team owner.<br><br>
+
+If it was not you who requested this invitation, please ignore this ema il, or instantly revoke the invitation by
+clicking here: <a href="{{ $invitation_link }}/revoke">Revoke Invitation</a><br><br>
+
+Thank you.
diff --git a/resources/views/emails/test-email.blade.php b/resources/views/emails/test-email.blade.php
deleted file mode 100644
index 3ad0eb0b0c..0000000000
--- a/resources/views/emails/test-email.blade.php
+++ /dev/null
@@ -1 +0,0 @@
-Hello from test email.
diff --git a/resources/views/emails/test.blade.php b/resources/views/emails/test.blade.php
new file mode 100644
index 0000000000..9c931db198
--- /dev/null
+++ b/resources/views/emails/test.blade.php
@@ -0,0 +1 @@
+Hello from test email. If you are seeing this, it means that your SMTP settings are working.
diff --git a/resources/views/livewire/settings/email.blade.php b/resources/views/livewire/settings/email.blade.php
index 6b3e9440ca..1e0511de2b 100644
--- a/resources/views/livewire/settings/email.blade.php
+++ b/resources/views/livewire/settings/email.blade.php
@@ -8,8 +8,6 @@
</div>
<div class="pt-2 pb-4 text-sm">SMTP settings for password reset, invitation, etc.</div>
<div class="flex items-end gap-2">
- <x-forms.input required id="settings.extra_attributes.smtp_recipients"
- helper="Email list to send the all notifications to, separated by comma." label="Recipient(s)" />
<x-forms.input id="settings.extra_attributes.smtp_test_recipients" label="Test Recipient(s)"
helper="Email list to send a test email to, separated by comma." />
<x-forms.button wire:click='test_email'>
diff --git a/resources/views/livewire/switch-team.blade.php b/resources/views/livewire/switch-team.blade.php
index 6648591e98..63c19b0ede 100644
--- a/resources/views/livewire/switch-team.blade.php
+++ b/resources/views/livewire/switch-team.blade.php
@@ -1,5 +1,5 @@
<div class="w-64 -mt-9">
- <x-forms.select wire:model="selectedTeamId" class="pr-0 select-xs ">
+ <x-forms.select wire:model="selectedTeamId">
<option value="default" disabled selected>Switch team</option>
@foreach (auth()->user()->teams as $team)
<option value="{{ $team->id }}">{{ $team->name }}</option>
diff --git a/resources/views/livewire/team/invitations.blade.php b/resources/views/livewire/team/invitations.blade.php
new file mode 100644
index 0000000000..fcb477a0a8
--- /dev/null
+++ b/resources/views/livewire/team/invitations.blade.php
@@ -0,0 +1,36 @@
+<div>
+ @if ($invitations->count() > 0)
+ <h4 class="pb-2">Pending Invitations</h4>
+ <div class="overflow-x-auto">
+ <table class="table">
+ <thead>
+ <tr class="font-bold text-white uppercase border-coolgray-200">
+ <th>Email</th>
+ <th>Via</th>
+ <th>Role</th>
+ <th>Invitation Link</th>
+ <th>Actions</th>
+ </tr>
+ </thead>
+ <tbody x-data>
+
+ @foreach ($invitations as $invite)
+ <tr class="border-coolgray-200">
+ <td>{{ $invite->email }}</td>
+ <td>{{ $invite->via }}</td>
+ <td>{{ $invite->role }}</td>
+ <td x-on:click="copyToClipboard('{{ $invite->link }}')">
+ <x-forms.button>Copy Invitation Link</x-forms.button>
+ </td>
+ <td>
+ <x-forms.button wire:click.prevent='deleteInvitation({{ $invite->id }})'>Revoke
+ Invitation</x-forms.button>
+ </td>
+ </tr>
+ @endforeach
+ </tbody>
+ </table>
+ </div>
+
+ @endif
+</div>
diff --git a/resources/views/livewire/team/invite-link.blade.php b/resources/views/livewire/team/invite-link.blade.php
index fce4cadc0b..df7f3bf18c 100644
--- a/resources/views/livewire/team/invite-link.blade.php
+++ b/resources/views/livewire/team/invite-link.blade.php
@@ -1,6 +1,13 @@
<div>
<form wire:submit.prevent='inviteByLink' class="flex items-center gap-2">
<x-forms.input id="email" type="email" name="email" placeholder="Email" />
- <x-forms.button type="submit">Invite with link</x-forms.button>
+ <x-forms.select id="role" name="role">
+ <option value="admin">Admin</option>
+ <option value="member">Member</option>
+ </x-forms.select>
+ <x-forms.button type="submit">Generate Invitation Link</x-forms.button>
+ @if (is_transactional_emails_active())
+ <x-forms.button wire:click.prevent='viaEmail'>Send Invitation Email</x-forms.button>
+ @endif
</form>
</div>
diff --git a/resources/views/livewire/team/member.blade.php b/resources/views/livewire/team/member.blade.php
index 55164cc3a6..a287c5f806 100644
--- a/resources/views/livewire/team/member.blade.php
+++ b/resources/views/livewire/team/member.blade.php
@@ -9,9 +9,9 @@
@if ($member->id !== auth()->user()->id)
@if (data_get($member, 'pivot.role') !== 'owner')
@if (data_get($member, 'pivot.role') !== 'admin')
- <x-forms.button wire:click="makeAdmin">Make admin</x-forms.button>
+ <x-forms.button wire:click="makeAdmin">Convert to Admin</x-forms.button>
@else
- <x-forms.button wire:click="makeReadonly">Make readonly</x-forms.button>
+ <x-forms.button wire:click="makeReadonly">Convert to Member</x-forms.button>
@endif
<x-forms.button wire:click="remove">Remove</x-forms.button>
@else
diff --git a/resources/views/team/show.blade.php b/resources/views/team/show.blade.php
index c9262cdbd7..778122cd4e 100644
--- a/resources/views/team/show.blade.php
+++ b/resources/views/team/show.blade.php
@@ -4,7 +4,7 @@
<div class="overflow-x-auto">
<table class="table">
<thead>
- <tr class="text-warning border-coolgray-200">
+ <tr class="font-bold text-white uppercase border-coolgray-200">
<th>Name</th>
<th>Email</th>
<th>Role</th>
@@ -29,22 +29,17 @@
</div>
@else
<div class="py-4">
- <h3 class="pb-4">Invite a new member</h3>
- <livewire:team.invite-link />
- <div class="text-sm text-warning">You need to configure SMTP settings before you can invite a new member
+ <h3>Invite a new member</h3>
+ <div class="pb-4 text-xs text-warning">You need to configure SMTP settings before you can invite a new
+ member
via
email.
</div>
+ <livewire:team.invite-link />
</div>
- @if ($invitations->count() > 0)
- <h2 class="pb-2">Pending Invitations</h2>
- @endif
- @foreach ($invitations as $invite)
- <div class="flex gap-2 text-sm">
- <div>{{ $invite->email }}</div>
- <div>Sent: {{ $invite->created_at }}</div>
- </div>
- @endforeach
+
+
+ <livewire:team.invitations :invitations="$invitations" />
@endif
@endif
</x-layout>
diff --git a/routes/api.php b/routes/api.php
index 62d3a48518..1bac5f6b26 100644
--- a/routes/api.php
+++ b/routes/api.php
@@ -1,7 +1,5 @@
<?php
-use App\Models\GithubApp;
-use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
/*
@@ -18,10 +16,3 @@ use Illuminate\Support\Facades\Route;
Route::get('/health', function () {
return 'OK';
});
-Route::get('/invitation/{uuid}', function () {
- ray('Invitation', request()->route('uuid'));
- return 'OK';
-});
-// Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
-// return $request->user();
-// });
diff --git a/routes/web.php b/routes/web.php
index 5effbbc754..1567ceb52e 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -57,6 +57,8 @@ Route::middleware(['auth'])->group(function () {
Route::get('/profile/team', [Controller::class, 'team'])->name('team.show');
Route::get('/profile/team/notifications', fn () => view('team.notifications'))->name('team.notifications');
Route::get('/command-center', fn () => view('command-center', ['servers' => Server::validated()->get()]))->name('command-center');
+ Route::get('/invitations/{uuid}', [Controller::class, 'accept_invitation'])->name('team.invitation.accept');
+ Route::get('/invitations/{uuid}/revoke', [Controller::class, 'revoke_invitation'])->name('team.invitation.revoke');
});
Route::middleware(['auth'])->group(function () {