updates
This commit is contained in:
parent
b097842d01
commit
a97d22b81b
@ -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 @@ public function emails()
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
21
app/Http/Livewire/Team/Invitations.php
Normal file
21
app/Http/Livewire/Team/Invitations.php
Normal file
@ -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();
|
||||
}
|
||||
}
|
@ -4,42 +4,64 @@
|
||||
|
||||
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' ? 'test@example.com' : '';
|
||||
$this->email = config('app.env') === 'local' ? 'test3@example.com' : '';
|
||||
}
|
||||
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 @@ public function inviteByLink()
|
||||
return general_error_handler(err: $e, that: $this, customErrorMessage: $error_message);
|
||||
}
|
||||
}
|
||||
public function inviteByLink()
|
||||
{
|
||||
$this->generate_invite_link();
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public function makeAdmin()
|
||||
}
|
||||
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()
|
||||
|
@ -18,7 +18,7 @@ public function scopeWithExtraAttributes(): Builder
|
||||
{
|
||||
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 === '') {
|
||||
|
@ -8,9 +8,11 @@ class TeamInvitation extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'team_id',
|
||||
'uuid',
|
||||
'email',
|
||||
'role',
|
||||
'link',
|
||||
'via',
|
||||
];
|
||||
public function team()
|
||||
{
|
||||
|
@ -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 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 @@ protected static function boot()
|
||||
$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 @@ public function isAdmin()
|
||||
($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;
|
||||
|
@ -12,11 +12,10 @@ public function send(SendsEmail $notifiable, Notification $notification): void
|
||||
{
|
||||
$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();
|
||||
}
|
||||
|
51
app/Notifications/Channels/TransactionalEmailChannel.php
Normal file
51
app/Notifications/Channels/TransactionalEmailChannel.php
Normal file
@ -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,
|
||||
]);
|
||||
}
|
||||
}
|
@ -12,20 +12,6 @@
|
||||
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 @@ public function via(object $notifiable): array
|
||||
$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 @@ public function toMail(object $notifiable): MailMessage
|
||||
->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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
26
app/Notifications/TransactionalEmails/TestEmail.php
Normal file
26
app/Notifications/TransactionalEmails/TestEmail.php
Normal file
@ -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;
|
||||
}
|
||||
}
|
@ -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');
|
||||
}
|
||||
|
9
config/constants.php
Normal file
9
config/constants.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
return [
|
||||
'invitation' => [
|
||||
'link' => [
|
||||
'base_url' => '/invitations/',
|
||||
'expiration' => 10,
|
||||
],
|
||||
],
|
||||
];
|
@ -15,7 +15,7 @@ public function up(): void
|
||||
$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']);
|
||||
|
@ -13,10 +13,12 @@ public function up(): void
|
||||
{
|
||||
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']);
|
||||
|
@ -16,7 +16,7 @@ public function run(): void
|
||||
'id' => 0,
|
||||
'is_registration_enabled' => true,
|
||||
'extra_attributes' => [
|
||||
'smtp_recipients' => 'test@example.com,test2@example.com',
|
||||
'smtp_test_recipients' => 'test@example.com,test2@example.com',
|
||||
'smtp_host' => 'coolify-mail',
|
||||
'smtp_port' => 1025,
|
||||
'smtp_from_address' => 'hi@localhost.com',
|
||||
|
@ -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'],
|
||||
|
@ -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>
|
||||
|
@ -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');
|
||||
|
@ -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'],
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
12
resources/views/emails/invitation-link.blade.php
Normal file
12
resources/views/emails/invitation-link.blade.php
Normal file
@ -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.
|
@ -1 +0,0 @@
|
||||
Hello from test email.
|
1
resources/views/emails/test.blade.php
Normal file
1
resources/views/emails/test.blade.php
Normal file
@ -0,0 +1 @@
|
||||
Hello from test email. If you are seeing this, it means that your SMTP settings are working.
|
@ -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'>
|
||||
|
@ -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>
|
||||
|
36
resources/views/livewire/team/invitations.blade.php
Normal file
36
resources/views/livewire/team/invitations.blade.php
Normal file
@ -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>
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -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>
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
use App\Models\GithubApp;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/*
|
||||
@ -18,10 +16,3 @@
|
||||
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();
|
||||
// });
|
||||
|
@ -57,6 +57,8 @@
|
||||
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 () {
|
||||
|
Loading…
Reference in New Issue
Block a user