chore: remove unused waitlist stuff
This commit is contained in:
@@ -1,114 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use App\Models\User;
|
|
||||||
use App\Models\Waitlist;
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
|
||||||
use Illuminate\Support\Facades\Crypt;
|
|
||||||
use Illuminate\Support\Facades\Hash;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
class WaitlistInvite extends Command
|
|
||||||
{
|
|
||||||
public Waitlist|User|null $next_patient = null;
|
|
||||||
|
|
||||||
public ?string $password = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'waitlist:invite {--people=1} {--only-email} {email?}';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Send invitation to the next user (or by email) in the waitlist';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
$people = $this->option('people');
|
|
||||||
for ($i = 0; $i < $people; $i++) {
|
|
||||||
$this->main();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function main()
|
|
||||||
{
|
|
||||||
if ($this->argument('email')) {
|
|
||||||
if ($this->option('only-email')) {
|
|
||||||
$this->next_patient = User::whereEmail($this->argument('email'))->first();
|
|
||||||
$this->password = Str::password();
|
|
||||||
$this->next_patient->update([
|
|
||||||
'password' => Hash::make($this->password),
|
|
||||||
'force_password_reset' => true,
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
$this->next_patient = Waitlist::where('email', $this->argument('email'))->first();
|
|
||||||
}
|
|
||||||
if (! $this->next_patient) {
|
|
||||||
$this->error("{$this->argument('email')} not found in the waitlist.");
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$this->next_patient = Waitlist::orderBy('created_at', 'asc')->where('verified', true)->first();
|
|
||||||
}
|
|
||||||
if ($this->next_patient) {
|
|
||||||
if ($this->option('only-email')) {
|
|
||||||
$this->send_email();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$this->register_user();
|
|
||||||
$this->remove_from_waitlist();
|
|
||||||
$this->send_email();
|
|
||||||
} else {
|
|
||||||
$this->info('No verified user found in the waitlist. 👀');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function register_user()
|
|
||||||
{
|
|
||||||
$already_registered = User::whereEmail($this->next_patient->email)->first();
|
|
||||||
if (! $already_registered) {
|
|
||||||
$this->password = Str::password();
|
|
||||||
User::create([
|
|
||||||
'name' => str($this->next_patient->email)->before('@'),
|
|
||||||
'email' => $this->next_patient->email,
|
|
||||||
'password' => Hash::make($this->password),
|
|
||||||
'force_password_reset' => true,
|
|
||||||
]);
|
|
||||||
$this->info("User registered ({$this->next_patient->email}) successfully. 🎉");
|
|
||||||
} else {
|
|
||||||
throw new \Exception('User already registered');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function remove_from_waitlist()
|
|
||||||
{
|
|
||||||
$this->next_patient->delete();
|
|
||||||
$this->info('User removed from waitlist successfully.');
|
|
||||||
}
|
|
||||||
|
|
||||||
private function send_email()
|
|
||||||
{
|
|
||||||
$token = Crypt::encryptString("{$this->next_patient->email}@@@$this->password");
|
|
||||||
$loginLink = route('auth.link', ['token' => $token]);
|
|
||||||
$mail = new MailMessage;
|
|
||||||
$mail->view('emails.waitlist-invitation', [
|
|
||||||
'loginLink' => $loginLink,
|
|
||||||
]);
|
|
||||||
$mail->subject('Congratulations! You are invited to join Coolify Cloud.');
|
|
||||||
send_user_an_email($mail, $this->next_patient->email);
|
|
||||||
$this->info('Email sent successfully. 📧');
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,63 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Webhook;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Models\Waitlist as ModelsWaitlist;
|
|
||||||
use Exception;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class Waitlist extends Controller
|
|
||||||
{
|
|
||||||
public function confirm(Request $request)
|
|
||||||
{
|
|
||||||
$email = request()->get('email');
|
|
||||||
$confirmation_code = request()->get('confirmation_code');
|
|
||||||
try {
|
|
||||||
$found = ModelsWaitlist::where('uuid', $confirmation_code)->where('email', $email)->first();
|
|
||||||
if ($found) {
|
|
||||||
if (! $found->verified) {
|
|
||||||
if ($found->created_at > now()->subMinutes(config('constants.waitlist.expiration'))) {
|
|
||||||
$found->verified = true;
|
|
||||||
$found->save();
|
|
||||||
send_internal_notification('Waitlist confirmed: '.$email);
|
|
||||||
|
|
||||||
return 'Thank you for confirming your email address. We will notify you when you are next in line.';
|
|
||||||
} else {
|
|
||||||
$found->delete();
|
|
||||||
send_internal_notification('Waitlist expired: '.$email);
|
|
||||||
|
|
||||||
return 'Your confirmation code has expired. Please sign up again.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
} catch (Exception $e) {
|
|
||||||
send_internal_notification('Waitlist confirmation failed: '.$e->getMessage());
|
|
||||||
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function cancel(Request $request)
|
|
||||||
{
|
|
||||||
$email = request()->get('email');
|
|
||||||
$confirmation_code = request()->get('confirmation_code');
|
|
||||||
try {
|
|
||||||
$found = ModelsWaitlist::where('uuid', $confirmation_code)->where('email', $email)->first();
|
|
||||||
if ($found && ! $found->verified) {
|
|
||||||
$found->delete();
|
|
||||||
send_internal_notification('Waitlist cancelled: '.$email);
|
|
||||||
|
|
||||||
return 'Your email address has been removed from the waitlist.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
} catch (Exception $e) {
|
|
||||||
send_internal_notification('Waitlist cancellation failed: '.$e->getMessage());
|
|
||||||
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Jobs;
|
|
||||||
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
|
|
||||||
class SendConfirmationForWaitlistJob implements ShouldBeEncrypted, ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
public function __construct(public string $email, public string $uuid) {}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$mail = new MailMessage;
|
|
||||||
$confirmation_url = base_url().'/webhooks/waitlist/confirm?email='.$this->email.'&confirmation_code='.$this->uuid;
|
|
||||||
$cancel_url = base_url().'/webhooks/waitlist/cancel?email='.$this->email.'&confirmation_code='.$this->uuid;
|
|
||||||
$mail->view('emails.waitlist-confirmation',
|
|
||||||
[
|
|
||||||
'confirmation_url' => $confirmation_url,
|
|
||||||
'cancel_url' => $cancel_url,
|
|
||||||
]);
|
|
||||||
$mail->subject('You are on the waitlist!');
|
|
||||||
send_user_an_email($mail, $this->email);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
send_internal_notification("SendConfirmationForWaitlistJob failed for {$this->email} with error: ".$e->getMessage());
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,70 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Livewire\Waitlist;
|
|
||||||
|
|
||||||
use App\Jobs\SendConfirmationForWaitlistJob;
|
|
||||||
use App\Models\User;
|
|
||||||
use App\Models\Waitlist;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Livewire\Component;
|
|
||||||
|
|
||||||
class Index extends Component
|
|
||||||
{
|
|
||||||
public string $email;
|
|
||||||
|
|
||||||
public int $users = 0;
|
|
||||||
|
|
||||||
public int $waitingInLine = 0;
|
|
||||||
|
|
||||||
protected $rules = [
|
|
||||||
'email' => 'required|email',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function render()
|
|
||||||
{
|
|
||||||
return view('livewire.waitlist.index')->layout('layouts.simple');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function mount()
|
|
||||||
{
|
|
||||||
if (config('constants.waitlist.enabled') == false) {
|
|
||||||
return redirect()->route('register');
|
|
||||||
}
|
|
||||||
$this->waitingInLine = Waitlist::whereVerified(true)->count();
|
|
||||||
$this->users = User::count();
|
|
||||||
if (isDev()) {
|
|
||||||
$this->email = 'waitlist@example.com';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function submit()
|
|
||||||
{
|
|
||||||
$this->validate();
|
|
||||||
try {
|
|
||||||
$already_registered = User::whereEmail($this->email)->first();
|
|
||||||
if ($already_registered) {
|
|
||||||
throw new \Exception('You are already on the waitlist or registered. <br>Please check your email to verify your email address or contact support.');
|
|
||||||
}
|
|
||||||
$found = Waitlist::where('email', $this->email)->first();
|
|
||||||
if ($found) {
|
|
||||||
if (! $found->verified) {
|
|
||||||
$this->dispatch('error', 'You are already on the waitlist. <br>Please check your email to verify your email address.');
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$this->dispatch('error', 'You are already on the waitlist. <br>You will be notified when your turn comes. <br>Thank you.');
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$waitlist = Waitlist::create([
|
|
||||||
'email' => Str::lower($this->email),
|
|
||||||
'type' => 'registration',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->dispatch('success', 'Check your email to verify your email address.');
|
|
||||||
dispatch(new SendConfirmationForWaitlistJob($this->email, $waitlist->uuid));
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
return handleError($e, $this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class Waitlist extends BaseModel
|
|
||||||
{
|
|
||||||
use HasFactory;
|
|
||||||
|
|
||||||
protected $guarded = [];
|
|
||||||
}
|
|
@@ -67,7 +67,6 @@ function allowedPathsForUnsubscribedAccounts()
|
|||||||
'subscription/new',
|
'subscription/new',
|
||||||
'login',
|
'login',
|
||||||
'logout',
|
'logout',
|
||||||
'waitlist',
|
|
||||||
'force-password-reset',
|
'force-password-reset',
|
||||||
'livewire/update',
|
'livewire/update',
|
||||||
];
|
];
|
||||||
|
@@ -77,11 +77,6 @@ return [
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
'waitlist' => [
|
|
||||||
'enabled' => env('WAITLIST', false),
|
|
||||||
'expiration' => 10,
|
|
||||||
],
|
|
||||||
|
|
||||||
'sentry' => [
|
'sentry' => [
|
||||||
'sentry_dsn' => env('SENTRY_DSN'),
|
'sentry_dsn' => env('SENTRY_DSN'),
|
||||||
],
|
],
|
||||||
|
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('waitlists');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::create('waitlists', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('uuid');
|
||||||
|
$table->string('type');
|
||||||
|
$table->string('email')->unique();
|
||||||
|
$table->boolean('verified')->default(false);
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@@ -1,7 +0,0 @@
|
|||||||
<x-emails.layout>
|
|
||||||
Someone added this email to the Coolify Cloud's waitlist. [Click here]({{ $confirmation_url }}) to confirm!
|
|
||||||
|
|
||||||
The link will expire in {{ config('constants.waitlist.expiration') }} minutes.
|
|
||||||
|
|
||||||
You have no idea what [Coolify Cloud](https://coolify.io) is or this waitlist? [Click here]({{ $cancel_url }}) to remove you from the waitlist.
|
|
||||||
</x-emails.layout>
|
|
@@ -1,37 +0,0 @@
|
|||||||
<div class="min-h-screen hero">
|
|
||||||
<div class="w-96 min-w-fit">
|
|
||||||
<div class="flex flex-col items-center pb-8">
|
|
||||||
<a href="{{ route('dashboard') }}">
|
|
||||||
<div class="text-5xl font-bold tracking-tight text-center dark:text-white">Coolify</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center justify-center pb-4 text-center">
|
|
||||||
<h2>Self-hosting in the cloud
|
|
||||||
<svg class="inline-block w-8 h-8 dark:text-warning width="512" height="512" viewBox="0 0 20 20"
|
|
||||||
xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<g fill="currentColor" fill-rule="evenodd" clip-rule="evenodd">
|
|
||||||
<path
|
|
||||||
d="M13 4h-1a4.002 4.002 0 0 0-3.874 3H8a4 4 0 1 0 0 8h8a4 4 0 0 0 .899-7.899A4.002 4.002 0 0 0 13 4Z"
|
|
||||||
opacity=".2" />
|
|
||||||
<path
|
|
||||||
d="M11 3h-1a4.002 4.002 0 0 0-3.874 3H6a4 4 0 1 0 0 8h8a4 4 0 0 0 .899-7.899A4.002 4.002 0 0 0 11 3ZM6.901 7l.193-.75A3.002 3.002 0 0 1 10 4h1c1.405 0 2.614.975 2.924 2.325l.14.61l.61.141A3.001 3.001 0 0 1 14 13H6a3 3 0 1 1 0-6h.901Z" />
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
</h2>
|
|
||||||
</div>
|
|
||||||
<form class="flex items-end gap-2" wire:submit='submit'>
|
|
||||||
<x-forms.input id="email" type="email" label="Email" placeholder="youareawesome@protonmail.com" />
|
|
||||||
<x-forms.button type="submit">Join Waitlist</x-forms.button>
|
|
||||||
</form>
|
|
||||||
<div>People waiting in the line: <span class="font-bold dark:text-warning">{{ $waitingInLine }}</div>
|
|
||||||
<div>Already using Coolify Cloud: <span class="font-bold dark:text-warning">{{ $users }}</div>
|
|
||||||
<div class="pt-8">
|
|
||||||
This is a paid & hosted version of Coolify.<br> See the pricing <a href="https://coolify.io/pricing"
|
|
||||||
class="dark:text-warning">here</a>.
|
|
||||||
</div>
|
|
||||||
<div class="pt-4">
|
|
||||||
If you are looking for the self-hosted version go <a href="https://coolify.io"
|
|
||||||
class="dark:text-warning">here</a>.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
@@ -5,7 +5,6 @@ use App\Http\Controllers\Webhook\Gitea;
|
|||||||
use App\Http\Controllers\Webhook\Github;
|
use App\Http\Controllers\Webhook\Github;
|
||||||
use App\Http\Controllers\Webhook\Gitlab;
|
use App\Http\Controllers\Webhook\Gitlab;
|
||||||
use App\Http\Controllers\Webhook\Stripe;
|
use App\Http\Controllers\Webhook\Stripe;
|
||||||
use App\Http\Controllers\Webhook\Waitlist;
|
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::get('/source/github/redirect', [Github::class, 'redirect']);
|
Route::get('/source/github/redirect', [Github::class, 'redirect']);
|
||||||
@@ -20,6 +19,3 @@ Route::post('/source/bitbucket/events/manual', [Bitbucket::class, 'manual']);
|
|||||||
Route::post('/source/gitea/events/manual', [Gitea::class, 'manual']);
|
Route::post('/source/gitea/events/manual', [Gitea::class, 'manual']);
|
||||||
|
|
||||||
Route::post('/payments/stripe/events', [Stripe::class, 'events']);
|
Route::post('/payments/stripe/events', [Stripe::class, 'events']);
|
||||||
|
|
||||||
Route::get('/waitlist/confirm', [Waitlist::class, 'confirm'])->name('webhooks.waitlist.confirm');
|
|
||||||
Route::get('/waitlist/cancel', [Waitlist::class, 'cancel'])->name('webhooks.waitlist.cancel');
|
|
||||||
|
Reference in New Issue
Block a user