diff --git a/app/Http/Controllers/ApplicationController.php b/app/Http/Controllers/ApplicationController.php index 41ae8f3ad..9b87492e4 100644 --- a/app/Http/Controllers/ApplicationController.php +++ b/app/Http/Controllers/ApplicationController.php @@ -12,7 +12,7 @@ class ApplicationController extends Controller public function configuration() { - $project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); + $project = auth()->user()->currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); if (!$project) { return redirect()->route('dashboard'); } @@ -29,7 +29,7 @@ public function configuration() public function deployments() { - $project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); + $project = auth()->user()->currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); if (!$project) { return redirect()->route('dashboard'); } @@ -49,7 +49,7 @@ public function deployment() { $deploymentUuid = request()->route('deployment_uuid'); - $project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); + $project = auth()->user()->currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); if (!$project) { return redirect()->route('dashboard'); } diff --git a/app/Http/Controllers/DatabaseController.php b/app/Http/Controllers/DatabaseController.php index 650051f06..bb6baf5ec 100644 --- a/app/Http/Controllers/DatabaseController.php +++ b/app/Http/Controllers/DatabaseController.php @@ -11,7 +11,7 @@ class DatabaseController extends Controller public function configuration() { - $project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); + $project = auth()->user()->currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); if (!$project) { return redirect()->route('dashboard'); } @@ -29,7 +29,7 @@ public function configuration() public function executions() { $backup_uuid = request()->route('backup_uuid'); - $project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); + $project = auth()->user()->currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); if (!$project) { return redirect()->route('dashboard'); } @@ -56,7 +56,7 @@ public function executions() public function backups() { - $project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); + $project = auth()->user()->currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); if (!$project) { return redirect()->route('dashboard'); } diff --git a/app/Http/Controllers/MagicController.php b/app/Http/Controllers/MagicController.php index e461cc70c..515bc14d1 100644 --- a/app/Http/Controllers/MagicController.php +++ b/app/Http/Controllers/MagicController.php @@ -41,7 +41,7 @@ public function newProject() { $project = Project::firstOrCreate( ['name' => request()->query('name') ?? generate_random_name()], - ['team_id' => session('currentTeam')->id] + ['team_id' => auth()->user()->currentTeam()->id] ); return response()->json([ 'project_uuid' => $project->uuid diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 9cab1063d..2ad941e92 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -18,7 +18,7 @@ public function all() public function edit() { $projectUuid = request()->route('project_uuid'); - $teamId = session('currentTeam')->id; + $teamId = auth()->user()->currentTeam()->id; $project = Project::where('team_id', $teamId)->where('uuid', $projectUuid)->first(); if (!$project) { return redirect()->route('dashboard'); @@ -29,7 +29,7 @@ public function edit() public function show() { $projectUuid = request()->route('project_uuid'); - $teamId = session('currentTeam')->id; + $teamId = auth()->user()->currentTeam()->id; $project = Project::where('team_id', $teamId)->where('uuid', $projectUuid)->first(); if (!$project) { @@ -44,7 +44,7 @@ public function new() $type = request()->query('type'); $destination_uuid = request()->query('destination'); - $project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); + $project = auth()->user()->currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); if (!$project) { return redirect()->route('dashboard'); } @@ -67,7 +67,7 @@ public function new() public function resources() { - $project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); + $project = auth()->user()->currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first(); if (!$project) { return redirect()->route('dashboard'); } diff --git a/app/Http/Livewire/Destination/New/StandaloneDocker.php b/app/Http/Livewire/Destination/New/StandaloneDocker.php index da4c453b7..fa884ec37 100644 --- a/app/Http/Livewire/Destination/New/StandaloneDocker.php +++ b/app/Http/Livewire/Destination/New/StandaloneDocker.php @@ -67,7 +67,7 @@ public function submit() 'name' => $this->name, 'network' => $this->network, 'server_id' => $this->server_id, - 'team_id' => session('currentTeam')->id + 'team_id' => auth()->user()->currentTeam()->id ]); } $this->createNetworkAndAttachToProxy(); diff --git a/app/Http/Livewire/PrivateKey/Change.php b/app/Http/Livewire/PrivateKey/Change.php index 1274910b2..d40e70e34 100644 --- a/app/Http/Livewire/PrivateKey/Change.php +++ b/app/Http/Livewire/PrivateKey/Change.php @@ -26,7 +26,7 @@ public function delete() try { if ($this->private_key->isEmpty()) { $this->private_key->delete(); - session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get(); + auth()->user()->currentTeam()->privateKeys = PrivateKey::where('team_id', auth()->user()->currentTeam()->id)->get(); return redirect()->route('private-key.all'); } $this->emit('error', 'This private key is in use and cannot be deleted. Please delete all servers, applications, and GitHub/GitLab apps that use this private key before deleting it.'); diff --git a/app/Http/Livewire/PrivateKey/Create.php b/app/Http/Livewire/PrivateKey/Create.php index 24e99cf85..82218f4a5 100644 --- a/app/Http/Livewire/PrivateKey/Create.php +++ b/app/Http/Livewire/PrivateKey/Create.php @@ -32,7 +32,7 @@ public function createPrivateKey() 'name' => $this->name, 'description' => $this->description, 'private_key' => $this->value, - 'team_id' => session('currentTeam')->id + 'team_id' => auth()->user()->currentTeam()->id ]); if ($this->from === 'server') { return redirect()->route('server.create'); diff --git a/app/Http/Livewire/Project/Application/Source.php b/app/Http/Livewire/Project/Application/Source.php index 1fec460d9..5affe9e45 100644 --- a/app/Http/Livewire/Project/Application/Source.php +++ b/app/Http/Livewire/Project/Application/Source.php @@ -29,7 +29,7 @@ public function mount() private function get_private_keys() { - $this->private_keys = PrivateKey::whereTeamId(session('currentTeam')->id)->get()->reject(function ($key) { + $this->private_keys = PrivateKey::whereTeamId(auth()->user()->currentTeam()->id)->get()->reject(function ($key) { return $key->id == $this->application->private_key_id; }); } diff --git a/app/Http/Livewire/Project/New/EmptyProject.php b/app/Http/Livewire/Project/New/EmptyProject.php index 931348a22..e77ab983e 100644 --- a/app/Http/Livewire/Project/New/EmptyProject.php +++ b/app/Http/Livewire/Project/New/EmptyProject.php @@ -11,7 +11,7 @@ public function createEmptyProject() { $project = Project::create([ 'name' => generate_random_name(), - 'team_id' => session('currentTeam')->id, + 'team_id' => auth()->user()->currentTeam()->id, ]); return redirect()->route('project.show', ['project_uuid' => $project->uuid, 'environment_name' => 'production']); } diff --git a/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php b/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php index 1bab8ce1f..a1f275f32 100644 --- a/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php +++ b/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php @@ -55,7 +55,7 @@ public function mount() } $this->parameters = get_route_parameters(); $this->query = request()->query(); - $this->private_keys = PrivateKey::where('team_id', session('currentTeam')->id)->where('id', '!=', 0)->get(); + $this->private_keys = PrivateKey::where('team_id', auth()->user()->currentTeam()->id)->where('id', '!=', 0)->get(); } public function instantSave() diff --git a/app/Http/Livewire/Server/Form.php b/app/Http/Livewire/Server/Form.php index d901dd2e6..4dcebc101 100644 --- a/app/Http/Livewire/Server/Form.php +++ b/app/Http/Livewire/Server/Form.php @@ -42,7 +42,7 @@ public function mount() public function installDocker() { - $activity = resolve(InstallDocker::class)($this->server, session('currentTeam')); + $activity = resolve(InstallDocker::class)($this->server, auth()->user()->currentTeam()); $this->emit('newMonitorActivity', $activity->id); } diff --git a/app/Http/Livewire/Server/New/ByIp.php b/app/Http/Livewire/Server/New/ByIp.php index 923bae039..233ea157d 100644 --- a/app/Http/Livewire/Server/New/ByIp.php +++ b/app/Http/Livewire/Server/New/ByIp.php @@ -64,7 +64,7 @@ public function submit() 'ip' => $this->ip, 'user' => $this->user, 'port' => $this->port, - 'team_id' => session('currentTeam')->id, + 'team_id' => auth()->user()->currentTeam()->id, 'private_key_id' => $this->private_key_id, ]); $server->settings->is_part_of_swarm = $this->is_part_of_swarm; diff --git a/app/Http/Livewire/Source/Github/Create.php b/app/Http/Livewire/Source/Github/Create.php index 29ff37dfc..862964c45 100644 --- a/app/Http/Livewire/Source/Github/Create.php +++ b/app/Http/Livewire/Source/Github/Create.php @@ -40,7 +40,7 @@ public function createGitHubApp() 'custom_user' => $this->custom_user, 'custom_port' => $this->custom_port, 'is_system_wide' => $this->is_system_wide, - 'team_id' => session('currentTeam')->id, + 'team_id' => auth()->user()->currentTeam()->id, ]); redirect()->route('source.github.show', ['github_app_uuid' => $github_app->uuid]); } catch (\Exception $e) { diff --git a/app/Http/Livewire/Team/Delete.php b/app/Http/Livewire/Team/Delete.php index f25a8b8d8..d14e82ccc 100644 --- a/app/Http/Livewire/Team/Delete.php +++ b/app/Http/Livewire/Team/Delete.php @@ -9,7 +9,7 @@ class Delete extends Component { public function delete() { - $currentTeam = session('currentTeam'); + $currentTeam = auth()->user()->currentTeam(); $currentTeam->delete(); $team = auth()->user()->teams()->first(); diff --git a/app/Http/Livewire/Team/Form.php b/app/Http/Livewire/Team/Form.php index 56bd21db6..eedd60c83 100644 --- a/app/Http/Livewire/Team/Form.php +++ b/app/Http/Livewire/Team/Form.php @@ -19,7 +19,7 @@ class Form extends Component public function mount() { - $this->team = session('currentTeam'); + $this->team = auth()->user()->currentTeam(); } public function submit() diff --git a/app/Http/Livewire/Team/InviteLink.php b/app/Http/Livewire/Team/InviteLink.php index d52533012..ddbe75182 100644 --- a/app/Http/Livewire/Team/InviteLink.php +++ b/app/Http/Livewire/Team/InviteLink.php @@ -35,9 +35,9 @@ private function generate_invite_link(bool $isEmail = false) return general_error_handler(that: $this, customErrorMessage: "$this->email must be registered first (or activate transactional emails to invite via email)."); } - $member_emails = session('currentTeam')->members()->get()->pluck('email'); + $member_emails = auth()->user()->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 . "."); + return general_error_handler(that: $this, customErrorMessage: "$this->email is already a member of " . auth()->user()->currentTeam()->name . "."); } $invitation = TeamInvitation::whereEmail($this->email); @@ -53,7 +53,7 @@ private function generate_invite_link(bool $isEmail = false) } TeamInvitation::firstOrCreate([ - 'team_id' => session('currentTeam')->id, + 'team_id' => auth()->user()->currentTeam()->id, 'uuid' => $uuid, 'email' => $this->email, 'role' => $this->role, diff --git a/app/Http/Livewire/Team/Member.php b/app/Http/Livewire/Team/Member.php index c356de75d..237d38818 100644 --- a/app/Http/Livewire/Team/Member.php +++ b/app/Http/Livewire/Team/Member.php @@ -11,19 +11,19 @@ class Member extends Component public function makeAdmin() { - $this->member->teams()->updateExistingPivot(session('currentTeam')->id, ['role' => 'admin']); + $this->member->teams()->updateExistingPivot(auth()->user()->currentTeam()->id, ['role' => 'admin']); $this->emit('reloadWindow'); } public function makeReadonly() { - $this->member->teams()->updateExistingPivot(session('currentTeam')->id, ['role' => 'member']); + $this->member->teams()->updateExistingPivot(auth()->user()->currentTeam()->id, ['role' => 'member']); $this->emit('reloadWindow'); } public function remove() { - $this->member->teams()->detach(session('currentTeam')); + $this->member->teams()->detach(auth()->user()->currentTeam()); $this->emit('reloadWindow'); } } diff --git a/app/Models/EnvironmentVariable.php b/app/Models/EnvironmentVariable.php index 23a420ef5..7bbc98014 100644 --- a/app/Models/EnvironmentVariable.php +++ b/app/Models/EnvironmentVariable.php @@ -41,7 +41,7 @@ protected function value(): Attribute private function get_environment_variables(string $environment_variable): string|null { - // $team_id = session('currentTeam')->id; + // $team_id = auth()->user()->currentTeam()->id; if (str_contains(trim($environment_variable), '{{') && str_contains(trim($environment_variable), '}}')) { $environment_variable = preg_replace('/\s+/', '', $environment_variable); $environment_variable = str_replace('{{', '', $environment_variable); diff --git a/app/Models/GithubApp.php b/app/Models/GithubApp.php index 8db24b900..c9badfed1 100644 --- a/app/Models/GithubApp.php +++ b/app/Models/GithubApp.php @@ -19,12 +19,12 @@ class GithubApp extends BaseModel static public function public() { - return GithubApp::whereTeamId(session('currentTeam')->id)->whereisPublic(true)->whereNotNull('app_id')->get(); + return GithubApp::whereTeamId(auth()->user()->currentTeam()->id)->whereisPublic(true)->whereNotNull('app_id')->get(); } static public function private() { - return GithubApp::whereTeamId(session('currentTeam')->id)->whereisPublic(false)->whereNotNull('app_id')->get(); + return GithubApp::whereTeamId(auth()->user()->currentTeam()->id)->whereisPublic(false)->whereNotNull('app_id')->get(); } protected static function booted(): void diff --git a/app/Models/PrivateKey.php b/app/Models/PrivateKey.php index 795ede3b7..4d59e9ca8 100644 --- a/app/Models/PrivateKey.php +++ b/app/Models/PrivateKey.php @@ -16,7 +16,7 @@ class PrivateKey extends BaseModel static public function ownedByCurrentTeam(array $select = ['*']) { $selectArray = collect($select)->concat(['id']); - return PrivateKey::whereTeamId(session('currentTeam')->id)->select($selectArray->all()); + return PrivateKey::whereTeamId(auth()->user()->currentTeam()->id)->select($selectArray->all()); } public function isEmpty() diff --git a/app/Models/Project.php b/app/Models/Project.php index 55bc0a6cf..a50dde167 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -13,7 +13,7 @@ class Project extends BaseModel static public function ownedByCurrentTeam() { - return Project::whereTeamId(session('currentTeam')->id)->orderBy('name'); + return Project::whereTeamId(auth()->user()->currentTeam()->id)->orderBy('name'); } protected static function booted() diff --git a/app/Models/S3Storage.php b/app/Models/S3Storage.php index 69be23f0a..5cd2f1318 100644 --- a/app/Models/S3Storage.php +++ b/app/Models/S3Storage.php @@ -17,7 +17,7 @@ class S3Storage extends BaseModel static public function ownedByCurrentTeam(array $select = ['*']) { $selectArray = collect($select)->concat(['id']); - return S3Storage::whereTeamId(session('currentTeam')->id)->select($selectArray->all())->orderBy('name'); + return S3Storage::whereTeamId(auth()->user()->currentTeam()->id)->select($selectArray->all())->orderBy('name'); } public function awsUrl() diff --git a/app/Models/Server.php b/app/Models/Server.php index 5f24de02b..91adb6b9b 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -34,7 +34,7 @@ static public function isReachable() static public function ownedByCurrentTeam(array $select = ['*']) { $selectArray = collect($select)->concat(['id']); - return Server::whereTeamId(session('currentTeam')->id)->with('settings')->select($selectArray->all())->orderBy('name'); + return Server::whereTeamId(auth()->user()->currentTeam()->id)->with('settings')->select($selectArray->all())->orderBy('name'); } static public function isUsable() diff --git a/app/Models/User.php b/app/Models/User.php index 47ed5a995..b37a070c3 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -79,7 +79,7 @@ public function isAdminFromSession() if ($is_part_of_root_team && $is_admin_of_root_team) { return true; } - $role = $teams->where('id', session('currentTeam')->id)->first()->pivot->role; + $role = $teams->where('id', auth()->user()->id)->first()->pivot->role; return $role === 'admin' || $role === 'owner'; } @@ -106,7 +106,7 @@ public function currentTeam() public function otherTeams() { - $team_id = session('currentTeam')->id; + $team_id = auth()->user()->currentTeam()->id; return auth()->user()->teams->filter(function ($team) use ($team_id) { return $team->id != $team_id; }); @@ -117,12 +117,12 @@ public function role() if ($this->teams()->where('team_id', 0)->first()) { return 'admin'; } - return $this->teams()->where('team_id', session('currentTeam')->id)->first()->pivot->role; + return $this->teams()->where('team_id', auth()->user()->currentTeam()->id)->first()->pivot->role; } public function resources() { - $team_id = session('currentTeam')->id; + $team_id = auth()->user()->currentTeam()->id; $data = Application::where('team_id', $team_id)->get(); return $data; } diff --git a/bootstrap/helpers/remoteProcess.php b/bootstrap/helpers/remoteProcess.php index 422b9c2ee..2fe78960b 100644 --- a/bootstrap/helpers/remoteProcess.php +++ b/bootstrap/helpers/remoteProcess.php @@ -158,8 +158,8 @@ function refreshPrivateKey(PrivateKey $private_key) foreach ($private_key->servers as $server) { // Delete the old ssh mux file to force a new one to be created Storage::disk('ssh-mux')->delete($server->muxFilename()); - if (session('currentTeam')->id) { - session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get(); + if (auth()->user()->currentTeam()->id) { + auth()->user()->currentTeam()->privateKeys = PrivateKey::where('team_id', auth()->user()->currentTeam()->id)->get(); } } } diff --git a/resources/views/livewire/team/delete.blade.php b/resources/views/livewire/team/delete.blade.php index da158ce58..b25b2e303 100644 --- a/resources/views/livewire/team/delete.blade.php +++ b/resources/views/livewire/team/delete.blade.php @@ -15,7 +15,7 @@ auth()->user()->currentTeam()->subscription?->lemon_status !== 'cancelled')
Name | -Role | -Actions | -|
---|---|---|---|
Name | +Role | +Actions | +