fix: routing, switch back to old one

This commit is contained in:
Andras Bacsai
2023-12-27 16:45:01 +01:00
parent 8c20c833ba
commit f03aa57758
70 changed files with 961 additions and 322 deletions

View File

@@ -47,7 +47,7 @@ class Handler extends ExceptionHandler
if ($request->is('api/*') || $request->expectsJson() || $this->shouldReturnJson($request, $exception)) {
return response()->json(['message' => $exception->getMessage()], 401);
}
return redirect()->guest($exception->redirectTo() ?? route('login'));
return redirect()->guest($exception->redirectTo() ?? route('login'));
}
/**
* Register the exception handling callbacks for the application.

View File

@@ -2,6 +2,7 @@
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -16,7 +17,7 @@ class DecideWhatToDoWithUser
}
if (!auth()->user() || !isCloud() || isInstanceAdmin()) {
if (!isCloud() && showBoarding() && !in_array($request->path(), allowedPathsForBoardingAccounts())) {
return redirect('boarding');
return redirect()->route('boarding');
}
return $next($request);
}
@@ -24,27 +25,27 @@ class DecideWhatToDoWithUser
if ($request->path() === 'verify' || in_array($request->path(), allowedPathsForInvalidAccounts()) || $request->routeIs('verify.verify')) {
return $next($request);
}
return redirect('/verify');
return redirect()-route('verify.email');
}
if (!isSubscriptionActive() && !isSubscriptionOnGracePeriod()) {
if (!in_array($request->path(), allowedPathsForUnsubscribedAccounts())) {
if (Str::startsWith($request->path(), 'invitations')) {
return $next($request);
}
return redirect('subscription');
return redirect()->route('subscription');
}
}
if (showBoarding() && !in_array($request->path(), allowedPathsForBoardingAccounts())) {
if (Str::startsWith($request->path(), 'invitations')) {
return $next($request);
}
return redirect('boarding');
return redirect()->route('boarding');
}
if (auth()->user()->hasVerifiedEmail() && $request->path() === 'verify') {
return redirect('/');
return redirect(RouteServiceProvider::HOME);
}
if (isSubscriptionActive() && $request->path() === 'subscription') {
return redirect('/');
return redirect(RouteServiceProvider::HOME);
}
return $next($request);
}

View File

@@ -37,7 +37,7 @@ class CheckLicense extends Component
} catch (\Throwable $e) {
session()->flash('error', 'Something went wrong. Please contact support. <br>Error: ' . $e->getMessage());
ray($e->getMessage());
return $this->redirect('/settings/license', navigate: true);
return redirect()->route('settings.license');
}
}
}

View File

@@ -36,7 +36,7 @@ class Form extends Component
instant_remote_process(['docker network rm -f ' . $this->destination->network], $this->destination->server);
}
$this->destination->delete();
return $this->redirectRoute('dashboard', navigate: true);
return redirect()->route('dashboard');
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -86,7 +86,7 @@ class Docker extends Component
}
}
$this->createNetworkAndAttachToProxy();
return $this->redirectRoute('destination.show', $docker->uuid, navigate: true);
return redirect()->route('destination.show', $docker->uuid);
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -35,7 +35,7 @@ class ForcePasswordReset extends Component
if ($firstLogin) {
send_internal_notification('First login for ' . auth()->user()->email);
}
return $this->redirectRoute('dashboard', navigate: true);
return redirect()->route('dashboard');
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -35,7 +35,7 @@ class Change extends Component
if ($this->private_key->isEmpty()) {
$this->private_key->delete();
currentTeam()->privateKeys = PrivateKey::where('team_id', currentTeam()->id)->get();
return $this->redirectRoute('security.private-key.index', navigate: true);
return redirect()->route('security.private-key.index');
}
$this->dispatch('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.');
} catch (\Throwable $e) {

View File

@@ -67,9 +67,9 @@ class Create extends Component
'team_id' => currentTeam()->id
]);
if ($this->from === 'server') {
return $this->redirectRoute('server.create', navigate: true);
return redirect()->route('server.create');
}
return $this->redirectRoute('security.private-key.show', ['private_key_uuid' => $private_key->uuid], navigate: true);
return redirect()->route('security.private-key.show', ['private_key_uuid' => $private_key->uuid]);
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -27,7 +27,7 @@ class AddEmpty extends Component
'description' => $this->description,
'team_id' => currentTeam()->id,
]);
return $this->redirectRoute('project.show', $project->uuid, navigate: true);
return redirect()->route('project.show', $project->uuid);
} catch (\Throwable $e) {
return handleError($e, $this);
} finally {

View File

@@ -27,10 +27,10 @@ class AddEnvironment extends Component
'project_id' => $this->project->id,
]);
return $this->redirectRoute('project.resources', [
return redirect()->route('project.resources', [
'project_uuid' => $this->project->uuid,
'environment_name' => $environment->name,
], navigate: true);
]);
} catch (\Throwable $e) {
handleError($e, $this);
} finally {

View File

@@ -15,15 +15,15 @@ class Configuration extends Component
{
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
if (!$project) {
return $this->redirectRoute('dashboard', navigate: true);
return redirect()->route('dashboard');
}
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
if (!$environment) {
return $this->redirectRoute('dashboard', navigate: true);
return redirect()->route('dashboard');
}
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
if (!$application) {
return $this->redirectRoute('dashboard', navigate: true);
return redirect()->route('dashboard');
}
$this->application = $application;
$mainServer = $this->application->destination->server;

View File

@@ -60,12 +60,12 @@ class Heading extends Component
force_rebuild: false,
is_new_deployment: true,
);
return $this->redirectRoute('project.application.deployment', [
return redirect()->route('project.application.deployment', [
'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $this->deploymentUuid,
'environment_name' => $this->parameters['environment_name'],
], navigate: true);
]);
}
public function deploy(bool $force_rebuild = false)
{
@@ -83,12 +83,12 @@ class Heading extends Component
deployment_uuid: $this->deploymentUuid,
force_rebuild: $force_rebuild,
);
$this->redirectRoute('project.application.deployment', [
return redirect()->route('project.application.deployment', [
'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $this->deploymentUuid,
'environment_name' => $this->parameters['environment_name'],
], navigate: true);
]);
}
protected function setDeploymentUuid()
@@ -113,12 +113,12 @@ class Heading extends Component
restart_only: true,
is_new_deployment: true,
);
return $this->redirectRoute('project.application.deployment', [
return redirect()->route('project.application.deployment', [
'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $this->deploymentUuid,
'environment_name' => $this->parameters['environment_name'],
], navigate: true);
]);
}
public function restart()
{
@@ -128,11 +128,11 @@ class Heading extends Component
deployment_uuid: $this->deploymentUuid,
restart_only: true,
);
return $this->redirectRoute('project.application.deployment', [
return redirect()->route('project.application.deployment', [
'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $this->deploymentUuid,
'environment_name' => $this->parameters['environment_name'],
], navigate: true);
]);
}
}

View File

@@ -52,12 +52,12 @@ class Previews extends Component
force_rebuild: true,
pull_request_id: $pull_request_id,
);
return $this->redirectRoute('project.application.deployment', [
return redirect()->route('project.application.deployment', [
'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $this->deployment_uuid,
'environment_name' => $this->parameters['environment_name'],
], navigate: true);
]);
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -29,12 +29,12 @@ class Rollback extends Component
commit: $commit,
force_rebuild: false,
);
return $this->redirectRoute('project.application.deployment', [
return redirect()->route('project.application.deployment', [
'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $deployment_uuid,
'environment_name' => $this->parameters['environment_name'],
], navigate: true);
]);
}
public function loadImages($showToast = false)

View File

@@ -152,10 +152,10 @@ class CloneProject extends Component
}
$newService->parse();
}
return $this->redirectRoute('project.resources', [
return redirect()->route('project.resources', [
'project_uuid' => $newProject->uuid,
'environment_name' => $newEnvironment->name,
], navigate: true);
]);
} catch (\Exception $e) {
return handleError($e, $this);
}

View File

@@ -50,9 +50,9 @@ class BackupEdit extends Component
$url = $url->withoutQueryParameter('selectedBackupId');
$url = $url->withFragment('backups');
$url = $url->getPath() . "#{$url->getFragment()}";
return $this->redirect($url,navigate: true);
return redirect($url);
} else {
return $this->redirectRoute('project.database.backups.all', $this->parameters);
return redirect()->route('project.database.backups.all', $this->parameters);
}
}

View File

@@ -23,7 +23,7 @@ class DeleteEnvironment extends Component
$environment = Environment::findOrFail($this->environment_id);
if ($environment->isEmpty()) {
$environment->delete();
return $this->redirectRoute('project.show', ['project_uuid' => $this->parameters['project_uuid']], navigate: true);
return redirect()->route('project.show', ['project_uuid' => $this->parameters['project_uuid']]);
}
return $this->dispatch('error', 'Environment has defined resources, please delete them first.');
}

View File

@@ -25,6 +25,6 @@ class DeleteProject extends Component
return $this->dispatch('error', 'Project has resources defined, please delete them first.');
}
$project->delete();
return $this->redirectRoute('projects', navigate: true);
return redirect()->route('projects');
}
}

View File

@@ -69,12 +69,12 @@ class DockerCompose extends Component
$service->parse(isNew: true);
return $this->redirectRoute('project.service.configuration', [
return redirect()->route('project.service.configuration', [
'service_uuid' => $service->uuid,
'environment_name' => $environment->name,
'project_uuid' => $project->uuid,
]);
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -64,11 +64,11 @@ class DockerImage extends Component
'name' => 'docker-image-' . $application->uuid,
'fqdn' => $fqdn
]);
return $this->redirectRoute('project.application.configuration', [
return redirect()->route('project.application.configuration', [
'application_uuid' => $application->uuid,
'environment_name' => $environment->name,
'project_uuid' => $project->uuid,
], navigate: false);
]);
}
public function render()
{

View File

@@ -13,6 +13,6 @@ class EmptyProject extends Component
'name' => generate_random_name(),
'team_id' => currentTeam()->id,
]);
return $this->redirectRoute('project.show', ['project_uuid' => $project->uuid, 'environment_name' => 'production'], navigate: false);
return redirect()->route('project.show', ['project_uuid' => $project->uuid, 'environment_name' => 'production']);
}
}

View File

@@ -151,11 +151,11 @@ class GithubPrivateRepository extends Component
$application->name = generate_application_name($this->selected_repository_owner . '/' . $this->selected_repository_repo, $this->selected_branch_name, $application->uuid);
$application->save();
return $this->redirectRoute('project.application.configuration', [
return redirect()->route('project.application.configuration', [
'application_uuid' => $application->uuid,
'environment_name' => $environment->name,
'project_uuid' => $project->uuid,
], navigate: false);
]);
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -132,11 +132,11 @@ class GithubPrivateRepositoryDeployKey extends Component
$application->name = generate_random_name($application->uuid);
$application->save();
return $this->redirectRoute('project.application.configuration', [
return redirect()->route('project.application.configuration', [
'application_uuid' => $application->uuid,
'environment_name' => $environment->name,
'project_uuid' => $project->uuid,
], navigate: false);
]);
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -184,11 +184,11 @@ class PublicGitRepository extends Component
$application->fqdn = $fqdn;
$application->save();
return $this->redirectRoute('project.application.configuration', [
return redirect()->route('project.application.configuration', [
'application_uuid' => $application->uuid,
'environment_name' => $environment->name,
'project_uuid' => $project->uuid,
], navigate: false);
]);
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -55,10 +55,10 @@ class Select extends Component
public function updatedSelectedEnvironment()
{
return $this->redirectRoute('project.resources.new', [
return redirect()->route('project.resources.new', [
'project_uuid' => $this->parameters['project_uuid'],
'environment_name' => $this->selectedEnvironment,
], navigate: true);
]);
}
// public function addExistingPostgresql()

View File

@@ -70,10 +70,10 @@ CMD ["nginx", "-g", "daemon off;"]
'fqdn' => $fqdn
]);
return $this->redirectRoute('project.application.configuration', [
return redirect()->route('project.application.configuration', [
'application_uuid' => $application->uuid,
'environment_name' => $environment->name,
'project_uuid' => $project->uuid,
], navigate: false);
]);
}
}

View File

@@ -41,7 +41,7 @@ class Application extends Component
try {
$this->application->delete();
$this->dispatch('success', 'Application deleted successfully.');
return $this->redirectRoute('project.service.configuration', $this->parameters, navigate: true);
return redirect()->route('project.service.configuration', $this->parameters);
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -25,10 +25,10 @@ class Danger extends Component
{
try {
DeleteResourceJob::dispatchSync($this->resource);
return $this->redirectRoute('project.resources', [
return redirect()->route('project.resources', [
'project_uuid' => $this->projectUuid,
'environment_name' => $this->environmentName
], navigate: true);
]);
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -19,7 +19,7 @@ class Delete extends Component
return;
}
$this->server->delete();
return $this->redirectRoute('server.all', navigate: true);
return redirect()->route('server.all');
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -15,7 +15,7 @@ class Show extends Component
try {
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
if (is_null($this->server)) {
return $this->redirectRoute('server.all', navigate: true);
return redirect()->route('server.all');
}
} catch (\Throwable $e) {
return handleError($e, $this);

View File

@@ -43,7 +43,7 @@ class LogDrains extends Component
try {
$server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
if (is_null($server)) {
return $this->redirectRoute('server.all', navigate: true);
return redirect()->route('server.all');
}
$this->server = $server;
} catch (\Throwable $e) {

View File

@@ -93,7 +93,7 @@ class ByIp extends Component
$server->settings->is_swarm_worker = $this->is_swarm_worker;
$server->settings->save();
$server->addInitialNetwork();
return $this->redirectRoute('server.show', $server->uuid);
return redirect()->route('server.show', $server->uuid);
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -17,7 +17,7 @@ class Show extends Component
try {
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
if (is_null($this->server)) {
return $this->redirectRoute('server.all', navigate: true);
return redirect()->route('server.all');
}
$this->privateKeys = PrivateKey::ownedByCurrentTeam()->get()->where('is_git_related', false);
} catch (\Throwable $e) {

View File

@@ -15,7 +15,7 @@ class Logs extends Component
try {
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
if (is_null($this->server)) {
return $this->redirectRoute('server.all', navigate: true);
return redirect()->route('server.all');
}
} catch (\Throwable $e) {
return handleError($e, $this);

View File

@@ -20,7 +20,7 @@ class Show extends Component
try {
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
if (is_null($this->server)) {
return $this->redirectRoute('server.all', navigate: true);
return redirect()->route('server.all');
}
} catch (\Throwable $e) {
return handleError($e, $this);

View File

@@ -17,7 +17,7 @@ class Show extends Component
try {
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
if (is_null($this->server)) {
return $this->redirectRoute('server.all', navigate: true);
return redirect()->route('server.all');
}
} catch (\Throwable $e) {

View File

@@ -41,7 +41,7 @@ class Change extends Component
$github_app_uuid = request()->github_app_uuid;
$this->github_app = GithubApp::where('uuid', $github_app_uuid)->first();
if (!$this->github_app) {
return $this->redirectRoute('source.all', navigate: true);
return redirect()->route('source.all');
}
$settings = InstanceSettings::get();
$this->github_app->makeVisible('client_secret')->makeVisible('webhook_secret');
@@ -67,7 +67,7 @@ class Change extends Component
$type = data_get($parameters, 'type');
$destination = data_get($parameters, 'destination');
session()->forget('from');
return $this->redirectRoute($back, [
return redirect()->route($back, [
'environment_name' => $environment_name,
'project_uuid' => $project_uuid,
'type' => $type,
@@ -117,7 +117,7 @@ class Change extends Component
{
try {
$this->github_app->delete();
return $this->redirectRoute('source.all', navigate: true);
return redirect()->route('source.all');
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -48,7 +48,7 @@ class Create extends Component
if (session('from')) {
session(['from' => session('from') + ['source_id' => $github_app->id]]);
}
return $this->redirectRoute('source.github.show', ['github_app_uuid' => $github_app->uuid], navigate: true);
return redirect()->route('source.github.show', ['github_app_uuid' => $github_app->uuid]);
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -3,6 +3,7 @@
namespace App\Livewire\Subscription;
use App\Models\InstanceSettings;
use App\Providers\RouteServiceProvider;
use Livewire\Component;
class Show extends Component
@@ -11,7 +12,7 @@ class Show extends Component
public bool $alreadySubscribed = false;
public function mount() {
if (!isCloud()) {
return $this->redirect('/', navigate: true);
return redirect(RouteServiceProvider::HOME);
}
$this->settings = InstanceSettings::get();
$this->alreadySubscribed = currentTeam()->subscription()->exists();

View File

@@ -30,7 +30,7 @@ class Create extends Component
]);
auth()->user()->teams()->attach($team, ['role' => 'admin']);
refreshSession();
return $this->redirectRoute('team.index', navigate: true);
return redirect()->route('team.index');
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -24,6 +24,6 @@ class Delete extends Component
});
refreshSession();
return $this->redirectRoute('team.index', navigate: true);
return redirect()->route('team.index');
}
}

View File

@@ -65,7 +65,7 @@ class Create extends Component
$this->storage->team_id = currentTeam()->id;
$this->storage->testConnection();
$this->storage->save();
return $this->redirectRoute('team.storages.show', $this->storage->uuid, navigate: true);
return redirect()->route('team.storages.show', $this->storage->uuid);
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -43,7 +43,7 @@ class Form extends Component
{
try {
$this->storage->delete();
return $this->redirectRoute('team.storages.all', navigate: true);
return redirect()->route('team.storages.all');
} catch (\Throwable $e) {
return handleError($e, $this);
}

View File

@@ -24,7 +24,7 @@ class Index extends Component
public function mount()
{
if (config('coolify.waitlist') == false) {
return $this->redirectRoute('register', navigate: true);
return redirect()->route('register');
}
$this->waitingInLine = Waitlist::whereVerified(true)->count();
$this->users = User::count();

View File

@@ -31,9 +31,9 @@ class FortifyServiceProvider extends ServiceProvider
{
// First user (root) will be redirected to /settings instead of / on registration.
if ($request->user()->currentTeam->id === 0) {
return redirect('/settings');
return redirect()->route('settings.configuration');
}
return redirect('/');
return redirect(RouteServiceProvider::HOME);
}
});
}