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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix: should note delete personal teams
Andras Bacsai2ffc3f497ba8
diff --git a/app/Http/Middleware/DecideWhatToDoWithUser.php b/app/Http/Middleware/DecideWhatToDoWithUser.phpindex f4adaaa9b4..a531f2cf30 100644--- a/app/Http/Middleware/DecideWhatToDoWithUser.php+++ b/app/Http/Middleware/DecideWhatToDoWithUser.php@@ -12,6 +12,10 @@ class DecideWhatToDoWithUser{public function handle(Request $request, Closure $next): Response{+ if (auth()?->user()?->teams?->count() === 0) {+ $currentTeam = auth()->user()?->recreate_personal_team();+ refreshSession($currentTeam);+ }if(auth()?->user()?->currentTeam()){refreshSession(auth()->user()->currentTeam());}diff --git a/app/Livewire/Project/Shared/Logs.php b/app/Livewire/Project/Shared/Logs.phpindex 3070e6dcd7..2958a31fd0 100644--- a/app/Livewire/Project/Shared/Logs.php+++ b/app/Livewire/Project/Shared/Logs.php@@ -45,60 +45,64 @@ class Logs extends Component}public function mount(){- $this->containers = collect();- $this->servers = collect();- $this->parameters = get_route_parameters();- $this->query = request()->query();- if (data_get($this->parameters, 'application_uuid')) {- $this->type = 'application';- $this->resource = Application::where('uuid', $this->parameters['application_uuid'])->firstOrFail();- $this->status = $this->resource->status;- if ($this->resource->destination->server->isFunctional()) {- $this->servers = $this->servers->push($this->resource->destination->server);- }- foreach ($this->resource->additional_servers as $server) {- if ($server->isFunctional()) {- $this->servers = $this->servers->push($server);+ try {+ $this->containers = collect();+ $this->servers = collect();+ $this->parameters = get_route_parameters();+ $this->query = request()->query();+ if (data_get($this->parameters, 'application_uuid')) {+ $this->type = 'application';+ $this->resource = Application::where('uuid', $this->parameters['application_uuid'])->firstOrFail();+ $this->status = $this->resource->status;+ if ($this->resource->destination->server->isFunctional()) {+ $this->servers = $this->servers->push($this->resource->destination->server);}- }- } else if (data_get($this->parameters, 'database_uuid')) {- $this->type = 'database';- $resource = StandalonePostgresql::where('uuid', $this->parameters['database_uuid'])->first();- if (is_null($resource)) {- $resource = StandaloneRedis::where('uuid', $this->parameters['database_uuid'])->first();+ foreach ($this->resource->additional_servers as $server) {+ if ($server->isFunctional()) {+ $this->servers = $this->servers->push($server);+ }+ }+ } else if (data_get($this->parameters, 'database_uuid')) {+ $this->type = 'database';+ $resource = StandalonePostgresql::where('uuid', $this->parameters['database_uuid'])->first();if (is_null($resource)) {- $resource = StandaloneMongodb::where('uuid', $this->parameters['database_uuid'])->first();+ $resource = StandaloneRedis::where('uuid', $this->parameters['database_uuid'])->first();if (is_null($resource)) {- $resource = StandaloneMysql::where('uuid', $this->parameters['database_uuid'])->first();+ $resource = StandaloneMongodb::where('uuid', $this->parameters['database_uuid'])->first();if (is_null($resource)) {- $resource = StandaloneMariadb::where('uuid', $this->parameters['database_uuid'])->first();+ $resource = StandaloneMysql::where('uuid', $this->parameters['database_uuid'])->first();if (is_null($resource)) {- abort(404);+ $resource = StandaloneMariadb::where('uuid', $this->parameters['database_uuid'])->first();+ if (is_null($resource)) {+ abort(404);+ }}}}}- }- $this->resource = $resource;- $this->status = $this->resource->status;- if ($this->resource->destination->server->isFunctional()) {- $this->servers = $this->servers->push($this->resource->destination->server);- }- $this->container = $this->resource->uuid;- $this->containers->push($this->container);- } else if (data_get($this->parameters, 'service_uuid')) {- $this->type = 'service';- $this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail();- $this->resource->applications()->get()->each(function ($application) {- $this->containers->push(data_get($application, 'name') . '-' . data_get($this->resource, 'uuid'));- });- $this->resource->databases()->get()->each(function ($database) {- $this->containers->push(data_get($database, 'name') . '-' . data_get($this->resource, 'uuid'));- });+ $this->resource = $resource;+ $this->status = $this->resource->status;+ if ($this->resource->destination->server->isFunctional()) {+ $this->servers = $this->servers->push($this->resource->destination->server);+ }+ $this->container = $this->resource->uuid;+ $this->containers->push($this->container);+ } else if (data_get($this->parameters, 'service_uuid')) {+ $this->type = 'service';+ $this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail();+ $this->resource->applications()->get()->each(function ($application) {+ $this->containers->push(data_get($application, 'name') . '-' . data_get($this->resource, 'uuid'));+ });+ $this->resource->databases()->get()->each(function ($database) {+ $this->containers->push(data_get($database, 'name') . '-' . data_get($this->resource, 'uuid'));+ });- if ($this->resource->server->isFunctional()) {- $this->servers = $this->servers->push($this->resource->server);+ if ($this->resource->server->isFunctional()) {+ $this->servers = $this->servers->push($this->resource->server);+ }}+ } catch (\Exception $e) {+ return handleError($e, $this);}}diff --git a/app/Models/Team.php b/app/Models/Team.phpindex 024630f4a1..656c4009b5 100644--- a/app/Models/Team.php+++ b/app/Models/Team.php@@ -144,7 +144,6 @@ class Team extends Model implements SendsDiscord, SendsEmail$sources = collect([]);$github_apps = $this->hasMany(GithubApp::class)->whereisPublic(false)->get();$gitlab_apps = $this->hasMany(GitlabApp::class)->whereisPublic(false)->get();- // $bitbucket_apps = $this->hasMany(BitbucketApp::class)->get();$sources = $sources->merge($github_apps)->merge($gitlab_apps);return $sources;}diff --git a/app/Models/TeamInvitation.php b/app/Models/TeamInvitation.phpindex 75a726f9f4..8564a867f7 100644--- a/app/Models/TeamInvitation.php+++ b/app/Models/TeamInvitation.php@@ -26,6 +26,7 @@ class TeamInvitation extends Modelreturn true;} else {$this->delete();+ return false;}}}diff --git a/app/Models/User.php b/app/Models/User.phpindex f8507a6b9d..9581d1fa50 100644--- a/app/Models/User.php+++ b/app/Models/User.php@@ -50,6 +50,21 @@ class User extends Authenticatable implements SendsEmail$user->teams()->attach($new_team, ['role' => 'owner']);});}+ public function recreate_personal_team()+ {+ $team = [+ 'name' => $this->name . "'s Team",+ 'personal_team' => true,+ 'show_boarding' => true+ ];+ if ($this->id === 0) {+ $team['id'] = 0;+ $team['name'] = 'Root Team';+ }+ $new_team = Team::create($team);+ $this->teams()->attach($new_team, ['role' => 'owner']);+ return $new_team;+ }public function createToken(string $name, array $abilities = ['*'], DateTimeInterface $expiresAt = null){$plainTextToken = sprintf(diff --git a/app/Providers/FortifyServiceProvider.php b/app/Providers/FortifyServiceProvider.phpindex 630da761dc..77de80885c 100644--- a/app/Providers/FortifyServiceProvider.php+++ b/app/Providers/FortifyServiceProvider.php@@ -8,14 +8,12 @@ use App\Actions\Fortify\UpdateUserPassword;use App\Actions\Fortify\UpdateUserProfileInformation;use App\Models\InstanceSettings;use App\Models\User;-use App\Models\Waitlist;use Illuminate\Cache\RateLimiting\Limit;use Illuminate\Http\Request;use Illuminate\Support\Facades\Hash;use Illuminate\Support\Facades\RateLimiter;use Illuminate\Support\ServiceProvider;use Laravel\Fortify\Contracts\RegisterResponse;-use Laravel\Fortify\Features;use Laravel\Fortify\Fortify;class FortifyServiceProvider extends ServiceProvider@@ -76,7 +74,11 @@ class FortifyServiceProvider extends ServiceProvider) {$user->updated_at = now();$user->save();- session(['currentTeam' => $user->currentTeam = $user->teams->firstWhere('personal_team', true)]);+ $user->currentTeam = $user->teams->firstWhere('personal_team', true);+ if (!$user->currentTeam) {+ $user->currentTeam = $user->recreate_personal_team();+ }+ session(['currentTeam' => $user->currentTeam]);return $user;}});diff --git a/resources/views/livewire/team/index.blade.php b/resources/views/livewire/team/index.blade.phpindex 99637f17f5..882cacb944 100644--- a/resources/views/livewire/team/index.blade.php+++ b/resources/views/livewire/team/index.blade.php@@ -20,10 +20,11 @@<h4 class="pb-4">Delete Team</h4>@if (session('currentTeam.id') === 0)<div>This is the default team. You can't delete it.</div>- @elseif(auth()->user()->teams()->get()->count() === 1)- <div>You can't delete your last team.</div>+ @elseif(auth()->user()->teams()->get()->count() === 1 || auth()->user()->currentTeam()->personal_team)+ <div>You can't delete your last / personal team.</div>@elseif(currentTeam()->subscription && currentTeam()->subscription?->lemon_status !== 'cancelled')- <div>Please cancel your subscription <a class="text-white underline" href="{{route('subscription.show')}}">here</a> before delete this team.</div>+ <div>Please cancel your subscription <a class="text-white underline"+ href="{{ route('subscription.show') }}">here</a> before delete this team.</div>@else@if (currentTeam()->isEmpty())<div class="pb-4">This will delete your team. Beware! There is no coming back!</div>