switch to auth()->user from session

This commit is contained in:
Andras Bacsai 2023-08-11 17:31:53 +02:00
parent e60ec6c47e
commit 833e45155d
32 changed files with 90 additions and 77 deletions

View File

@ -12,7 +12,7 @@ class ApplicationController extends Controller
public function configuration() 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) { if (!$project) {
return redirect()->route('dashboard'); return redirect()->route('dashboard');
} }
@ -29,7 +29,7 @@ public function configuration()
public function deployments() 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) { if (!$project) {
return redirect()->route('dashboard'); return redirect()->route('dashboard');
} }
@ -49,7 +49,7 @@ public function deployment()
{ {
$deploymentUuid = request()->route('deployment_uuid'); $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) { if (!$project) {
return redirect()->route('dashboard'); return redirect()->route('dashboard');
} }

View File

@ -11,7 +11,7 @@ class DatabaseController extends Controller
public function configuration() 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) { if (!$project) {
return redirect()->route('dashboard'); return redirect()->route('dashboard');
} }
@ -29,7 +29,7 @@ public function configuration()
public function executions() public function executions()
{ {
$backup_uuid = request()->route('backup_uuid'); $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) { if (!$project) {
return redirect()->route('dashboard'); return redirect()->route('dashboard');
} }
@ -56,7 +56,7 @@ public function executions()
public function backups() 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) { if (!$project) {
return redirect()->route('dashboard'); return redirect()->route('dashboard');
} }

View File

@ -41,7 +41,7 @@ public function newProject()
{ {
$project = Project::firstOrCreate( $project = Project::firstOrCreate(
['name' => request()->query('name') ?? generate_random_name()], ['name' => request()->query('name') ?? generate_random_name()],
['team_id' => session('currentTeam')->id] ['team_id' => auth()->user()->currentTeam()->id]
); );
return response()->json([ return response()->json([
'project_uuid' => $project->uuid 'project_uuid' => $project->uuid

View File

@ -18,7 +18,7 @@ public function all()
public function edit() public function edit()
{ {
$projectUuid = request()->route('project_uuid'); $projectUuid = request()->route('project_uuid');
$teamId = session('currentTeam')->id; $teamId = auth()->user()->currentTeam()->id;
$project = Project::where('team_id', $teamId)->where('uuid', $projectUuid)->first(); $project = Project::where('team_id', $teamId)->where('uuid', $projectUuid)->first();
if (!$project) { if (!$project) {
return redirect()->route('dashboard'); return redirect()->route('dashboard');
@ -29,7 +29,7 @@ public function edit()
public function show() public function show()
{ {
$projectUuid = request()->route('project_uuid'); $projectUuid = request()->route('project_uuid');
$teamId = session('currentTeam')->id; $teamId = auth()->user()->currentTeam()->id;
$project = Project::where('team_id', $teamId)->where('uuid', $projectUuid)->first(); $project = Project::where('team_id', $teamId)->where('uuid', $projectUuid)->first();
if (!$project) { if (!$project) {
@ -44,7 +44,7 @@ public function new()
$type = request()->query('type'); $type = request()->query('type');
$destination_uuid = request()->query('destination'); $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) { if (!$project) {
return redirect()->route('dashboard'); return redirect()->route('dashboard');
} }
@ -67,7 +67,7 @@ public function new()
public function resources() 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) { if (!$project) {
return redirect()->route('dashboard'); return redirect()->route('dashboard');
} }

View File

@ -67,7 +67,7 @@ public function submit()
'name' => $this->name, 'name' => $this->name,
'network' => $this->network, 'network' => $this->network,
'server_id' => $this->server_id, 'server_id' => $this->server_id,
'team_id' => session('currentTeam')->id 'team_id' => auth()->user()->currentTeam()->id
]); ]);
} }
$this->createNetworkAndAttachToProxy(); $this->createNetworkAndAttachToProxy();

View File

@ -26,7 +26,7 @@ public function delete()
try { try {
if ($this->private_key->isEmpty()) { if ($this->private_key->isEmpty()) {
$this->private_key->delete(); $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'); 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.'); $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.');

View File

@ -32,7 +32,7 @@ public function createPrivateKey()
'name' => $this->name, 'name' => $this->name,
'description' => $this->description, 'description' => $this->description,
'private_key' => $this->value, 'private_key' => $this->value,
'team_id' => session('currentTeam')->id 'team_id' => auth()->user()->currentTeam()->id
]); ]);
if ($this->from === 'server') { if ($this->from === 'server') {
return redirect()->route('server.create'); return redirect()->route('server.create');

View File

@ -29,7 +29,7 @@ public function mount()
private function get_private_keys() 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; return $key->id == $this->application->private_key_id;
}); });
} }

View File

@ -11,7 +11,7 @@ public function createEmptyProject()
{ {
$project = Project::create([ $project = Project::create([
'name' => generate_random_name(), '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']); return redirect()->route('project.show', ['project_uuid' => $project->uuid, 'environment_name' => 'production']);
} }

View File

@ -55,7 +55,7 @@ public function mount()
} }
$this->parameters = get_route_parameters(); $this->parameters = get_route_parameters();
$this->query = request()->query(); $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() public function instantSave()

View File

@ -42,7 +42,7 @@ public function mount()
public function installDocker() 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); $this->emit('newMonitorActivity', $activity->id);
} }

View File

@ -64,7 +64,7 @@ public function submit()
'ip' => $this->ip, 'ip' => $this->ip,
'user' => $this->user, 'user' => $this->user,
'port' => $this->port, 'port' => $this->port,
'team_id' => session('currentTeam')->id, 'team_id' => auth()->user()->currentTeam()->id,
'private_key_id' => $this->private_key_id, 'private_key_id' => $this->private_key_id,
]); ]);
$server->settings->is_part_of_swarm = $this->is_part_of_swarm; $server->settings->is_part_of_swarm = $this->is_part_of_swarm;

View File

@ -40,7 +40,7 @@ public function createGitHubApp()
'custom_user' => $this->custom_user, 'custom_user' => $this->custom_user,
'custom_port' => $this->custom_port, 'custom_port' => $this->custom_port,
'is_system_wide' => $this->is_system_wide, '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]); redirect()->route('source.github.show', ['github_app_uuid' => $github_app->uuid]);
} catch (\Exception $e) { } catch (\Exception $e) {

View File

@ -9,7 +9,7 @@ class Delete extends Component
{ {
public function delete() public function delete()
{ {
$currentTeam = session('currentTeam'); $currentTeam = auth()->user()->currentTeam();
$currentTeam->delete(); $currentTeam->delete();
$team = auth()->user()->teams()->first(); $team = auth()->user()->teams()->first();

View File

@ -19,7 +19,7 @@ class Form extends Component
public function mount() public function mount()
{ {
$this->team = session('currentTeam'); $this->team = auth()->user()->currentTeam();
} }
public function submit() public function submit()

View File

@ -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)."); 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)) { 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); $invitation = TeamInvitation::whereEmail($this->email);
@ -53,7 +53,7 @@ private function generate_invite_link(bool $isEmail = false)
} }
TeamInvitation::firstOrCreate([ TeamInvitation::firstOrCreate([
'team_id' => session('currentTeam')->id, 'team_id' => auth()->user()->currentTeam()->id,
'uuid' => $uuid, 'uuid' => $uuid,
'email' => $this->email, 'email' => $this->email,
'role' => $this->role, 'role' => $this->role,

View File

@ -11,19 +11,19 @@ class Member extends Component
public function makeAdmin() 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'); $this->emit('reloadWindow');
} }
public function makeReadonly() 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'); $this->emit('reloadWindow');
} }
public function remove() public function remove()
{ {
$this->member->teams()->detach(session('currentTeam')); $this->member->teams()->detach(auth()->user()->currentTeam());
$this->emit('reloadWindow'); $this->emit('reloadWindow');
} }
} }

View File

@ -41,7 +41,7 @@ protected function value(): Attribute
private function get_environment_variables(string $environment_variable): string|null 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), '}}')) { if (str_contains(trim($environment_variable), '{{') && str_contains(trim($environment_variable), '}}')) {
$environment_variable = preg_replace('/\s+/', '', $environment_variable); $environment_variable = preg_replace('/\s+/', '', $environment_variable);
$environment_variable = str_replace('{{', '', $environment_variable); $environment_variable = str_replace('{{', '', $environment_variable);

View File

@ -19,12 +19,12 @@ class GithubApp extends BaseModel
static public function public() 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() 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 protected static function booted(): void

View File

@ -16,7 +16,7 @@ class PrivateKey extends BaseModel
static public function ownedByCurrentTeam(array $select = ['*']) static public function ownedByCurrentTeam(array $select = ['*'])
{ {
$selectArray = collect($select)->concat(['id']); $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() public function isEmpty()

View File

@ -13,7 +13,7 @@ class Project extends BaseModel
static public function ownedByCurrentTeam() 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() protected static function booted()

View File

@ -17,7 +17,7 @@ class S3Storage extends BaseModel
static public function ownedByCurrentTeam(array $select = ['*']) static public function ownedByCurrentTeam(array $select = ['*'])
{ {
$selectArray = collect($select)->concat(['id']); $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() public function awsUrl()

View File

@ -34,7 +34,7 @@ static public function isReachable()
static public function ownedByCurrentTeam(array $select = ['*']) static public function ownedByCurrentTeam(array $select = ['*'])
{ {
$selectArray = collect($select)->concat(['id']); $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() static public function isUsable()

View File

@ -79,7 +79,7 @@ public function isAdminFromSession()
if ($is_part_of_root_team && $is_admin_of_root_team) { if ($is_part_of_root_team && $is_admin_of_root_team) {
return true; 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'; return $role === 'admin' || $role === 'owner';
} }
@ -106,7 +106,7 @@ public function currentTeam()
public function otherTeams() 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 auth()->user()->teams->filter(function ($team) use ($team_id) {
return $team->id != $team_id; return $team->id != $team_id;
}); });
@ -117,12 +117,12 @@ public function role()
if ($this->teams()->where('team_id', 0)->first()) { if ($this->teams()->where('team_id', 0)->first()) {
return 'admin'; 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() public function resources()
{ {
$team_id = session('currentTeam')->id; $team_id = auth()->user()->currentTeam()->id;
$data = Application::where('team_id', $team_id)->get(); $data = Application::where('team_id', $team_id)->get();
return $data; return $data;
} }

View File

@ -158,8 +158,8 @@ function refreshPrivateKey(PrivateKey $private_key)
foreach ($private_key->servers as $server) { foreach ($private_key->servers as $server) {
// Delete the old ssh mux file to force a new one to be created // Delete the old ssh mux file to force a new one to be created
Storage::disk('ssh-mux')->delete($server->muxFilename()); Storage::disk('ssh-mux')->delete($server->muxFilename());
if (session('currentTeam')->id) { if (auth()->user()->currentTeam()->id) {
session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get(); auth()->user()->currentTeam()->privateKeys = PrivateKey::where('team_id', auth()->user()->currentTeam()->id)->get();
} }
} }
} }

View File

@ -15,7 +15,7 @@
auth()->user()->currentTeam()->subscription?->lemon_status !== 'cancelled') auth()->user()->currentTeam()->subscription?->lemon_status !== 'cancelled')
<div>Please cancel your subscription before delete this team (Manage My Subscription button).</div> <div>Please cancel your subscription before delete this team (Manage My Subscription button).</div>
@else @else
@if (session('currentTeam')->isEmpty()) @if (auth()->user()->currentTeam()->isEmpty())
<div class="pb-4">This will delete your team. Beware! There is no coming back!</div> <div class="pb-4">This will delete your team. Beware! There is no coming back!</div>
<x-forms.button isError isModal modalId="deleteTeam"> <x-forms.button isError isModal modalId="deleteTeam">
Delete Delete
@ -25,29 +25,29 @@
<div class="pb-4">You need to delete the following resources to be able to delete the team:</div> <div class="pb-4">You need to delete the following resources to be able to delete the team:</div>
<h4 class="pb-4">Projects:</h4> <h4 class="pb-4">Projects:</h4>
<ul class="pl-8 list-disc"> <ul class="pl-8 list-disc">
@foreach (session('currentTeam')->projects as $resource) @foreach (auth()->user()->currentTeam()->projects as $resource)
<li>{{ $resource->name }}</li> <li>{{ $resource->name }}</li>
@endforeach @endforeach
</ul> </ul>
<h4 class="py-4">Servers:</h4> <h4 class="py-4">Servers:</h4>
<ul class="pl-8 list-disc"> <ul class="pl-8 list-disc">
@foreach (session('currentTeam')->servers as $resource) @foreach (auth()->user()->currentTeam()->servers as $resource)
<li>{{ $resource->name }}</li> <li>{{ $resource->name }}</li>
@endforeach @endforeach
</ul> </ul>
<h4 class="py-4">Private Keys:</h4> <h4 class="py-4">Private Keys:</h4>
<ul class="pl-8 list-disc"> <ul class="pl-8 list-disc">
@foreach (session('currentTeam')->privateKeys as $resource) @foreach (auth()->user()->currentTeam()->privateKeys as $resource)
<li>{{ $resource->name }}</li> <li>{{ $resource->name }}</li>
@endforeach @endforeach
</ul> </ul>
<h4 class="py-4">Sources:</h4> <h4 class="py-4">Sources:</h4>
<ul class="pl-8 list-disc"> <ul class="pl-8 list-disc">
@foreach (session('currentTeam')->sources() as $resource) @foreach (auth()->user()->currentTeam()->sources() as $resource)
<li>{{ $resource->name }}</li> <li>{{ $resource->name }}</li>
@endforeach @endforeach
</ul> </ul>
@endif @endif
@endif @endif
</div> </div>

View File

@ -1,20 +1,22 @@
<x-layout> <x-layout>
<x-team.navbar :team="session('currentTeam')"/> <x-team.navbar :team="auth()
->user()
->currentTeam()" />
<h2>Members</h2> <h2>Members</h2>
<div class="pt-4 overflow-hidden"> <div class="pt-4 overflow-hidden">
<table> <table>
<thead> <thead>
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Email</th> <th>Email</th>
<th>Role</th> <th>Role</th>
<th>Actions</th> <th>Actions</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach (auth()->user()->currentTeam()->members->sortBy('name') as $member) @foreach (auth()->user()->currentTeam()->members->sortBy('name') as $member)
<livewire:team.member :member="$member" :wire:key="$member->id"/> <livewire:team.member :member="$member" :wire:key="$member->id" />
@endforeach @endforeach
</tbody> </tbody>
</table> </table>
</div> </div>
@ -26,7 +28,7 @@
<h3>Invite a new member</h3> <h3>Invite a new member</h3>
@if (auth()->user()->isInstanceAdmin()) @if (auth()->user()->isInstanceAdmin())
<div class="pb-4 text-xs text-warning">You need to configure <a href="/settings/emails" <div class="pb-4 text-xs text-warning">You need to configure <a href="/settings/emails"
class="underline text-warning">Transactional class="underline text-warning">Transactional
Emails</a> Emails</a>
before before
you can invite a you can invite a
@ -37,8 +39,8 @@ class="underline text-warning">Transactional
</div> </div>
@endif @endif
@endif @endif
<livewire:team.invite-link/> <livewire:team.invite-link />
</div> </div>
<livewire:team.invitations :invitations="$invitations"/> <livewire:team.invitations :invitations="$invitations" />
@endif @endif
</x-layout> </x-layout>

View File

@ -1,19 +1,25 @@
<x-layout> <x-layout>
<x-team.navbar :team="session('currentTeam')"/> <x-team.navbar :team="auth()
->user()
->currentTeam()" />
<h2 class="pb-4">Notifications</h2> <h2 class="pb-4">Notifications</h2>
<div x-data="{ activeTab: window.location.hash ? window.location.hash.substring(1) : 'email' }" class="flex h-full"> <div x-data="{ activeTab: window.location.hash ? window.location.hash.substring(1) : 'email' }" class="flex h-full">
<div class="flex flex-col gap-4 min-w-fit"> <div class="flex flex-col gap-4 min-w-fit">
<a :class="activeTab === 'email' && 'text-white'" <a :class="activeTab === 'email' && 'text-white'"
@click.prevent="activeTab = 'email'; window.location.hash = 'email'" href="#">Email</a> @click.prevent="activeTab = 'email'; window.location.hash = 'email'" href="#">Email</a>
<a :class="activeTab === 'discord' && 'text-white'" <a :class="activeTab === 'discord' && 'text-white'"
@click.prevent="activeTab = 'discord'; window.location.hash = 'discord'" href="#">Discord</a> @click.prevent="activeTab = 'discord'; window.location.hash = 'discord'" href="#">Discord</a>
</div> </div>
<div class="w-full pl-8"> <div class="w-full pl-8">
<div x-cloak x-show="activeTab === 'email'" class="h-full"> <div x-cloak x-show="activeTab === 'email'" class="h-full">
<livewire:notifications.email-settings :model="session('currentTeam')"/> <livewire:notifications.email-settings :model="auth()
->user()
->currentTeam()" />
</div> </div>
<div x-cloak x-show="activeTab === 'discord'"> <div x-cloak x-show="activeTab === 'discord'">
<livewire:notifications.discord-settings :model="session('currentTeam')"/> <livewire:notifications.discord-settings :model="auth()
->user()
->currentTeam()" />
</div> </div>
</div> </div>
</x-layout> </x-layout>

View File

@ -1,6 +1,8 @@
<x-layout> <x-layout>
<x-team.navbar :team="session('currentTeam')"/> <x-team.navbar :team="auth()
<livewire:team.form/> ->user()
->currentTeam()" />
<livewire:team.form />
@if (is_cloud()) @if (is_cloud())
<div class="pb-8"> <div class="pb-8">
<h3>Subscription</h3> <h3>Subscription</h3>
@ -27,5 +29,5 @@
</x-forms.button> </x-forms.button>
</div> </div>
@endif @endif
<livewire:team.delete/> <livewire:team.delete />
</x-layout> </x-layout>

View File

@ -1,5 +1,7 @@
<x-layout> <x-layout>
<x-team.navbar :team="session('currentTeam')"/> <x-team.navbar :team="auth()
->user()
->currentTeam()" />
<div class="flex items-start gap-2"> <div class="flex items-start gap-2">
<h2 class="pb-4">S3 Storages</h2> <h2 class="pb-4">S3 Storages</h2>
<x-forms.button class="btn"> <x-forms.button class="btn">
@ -8,8 +10,7 @@
</div> </div>
<div class="grid gap-2 lg:grid-cols-2"> <div class="grid gap-2 lg:grid-cols-2">
@forelse ($s3 as $storage) @forelse ($s3 as $storage)
<div x-data <div x-data x-on:click="goto('{{ $storage->uuid }}')" @class(['gap-2 border cursor-pointer box group border-transparent'])>
x-on:click="goto('{{ $storage->uuid }}')" @class(['gap-2 border cursor-pointer box group border-transparent'])>
<div class="flex flex-col mx-6"> <div class="flex flex-col mx-6">
<div class=" group-hover:text-white"> <div class=" group-hover:text-white">
{{ $storage->name }} {{ $storage->name }}
@ -21,7 +22,7 @@
@empty @empty
<div> <div>
<div>No storage found.</div> <div>No storage found.</div>
<x-use-magic-bar link="/team/storages/new"/> <x-use-magic-bar link="/team/storages/new" />
</div> </div>
@endforelse @endforelse
</div> </div>

View File

@ -1,4 +1,6 @@
<x-layout> <x-layout>
<x-team.navbar :team="session('currentTeam')"/> <x-team.navbar :team="auth()
<livewire:team.storage.form :storage="$storage"/> ->user()
->currentTeam()" />
<livewire:team.storage.form :storage="$storage" />
</x-layout> </x-layout>

View File

@ -122,7 +122,7 @@
Route::middleware(['auth'])->group(function () { Route::middleware(['auth'])->group(function () {
Route::get('/source/new', fn() => view('source.new'))->name('source.new'); Route::get('/source/new', fn() => view('source.new'))->name('source.new');
Route::get('/sources', function () { Route::get('/sources', function () {
$sources = session('currentTeam')->sources(); $sources = auth()->user()->currentTeam()->sources();
return view('source.all', [ return view('source.all', [
'sources' => $sources, 'sources' => $sources,
]); ]);