mirror of
https://github.com/projectsend/projectsend.git
synced 2026-09-17 17:15:08 +00:00
4ce6793da9
Setup ended by handing somebody a login form and an empty dashboard. Everything this application can do was one menu away, and which menu was theirs to discover. The first time the administrator signs in to a new installation they now land on a short ordered list of what is worth doing first — add a client, upload a file, group the people who get the same things, choose how the file lists and the email look, point it at a mail server, add the team, check the scheduler — each a link straight to the screen that does it. The list is filtered twice, and both filters matter. By permission, because a link that answers 403 is worse than no link. And by edition: a managed installation is not sent off to configure a mail server somebody else runs, to create staff accounts that are not its to create, or to check a scheduler it does not host. Those three drop out on Cloud and the other five remain. Two steps tick themselves, because the database can answer them: a client exists, a file exists. Nothing else is checkable without guessing — a theme that was never changed looks exactly like one chosen deliberately — and a tick meaning "we assume so" is worse than no tick. The invitation to the Discord is at the very bottom, after the list. Somebody who has just installed this came with a job in mind, and opening with a social invitation is the fastest way to lose them. The marker is raised where a first administrator comes into existence — the setup screen and `projectsend:admin`, so a container provisioned from environment variables is welcomed too — and it is false by default, so an installation that updates into this feature is not congratulated on an install it finished a year ago. RedirectToWhatsNew becomes RedirectToGreeting and answers for both: they are the same interruption, and a second middleware on the same route would have to know about the first to avoid arguing with it. Installing wins; release notes for a version you never ran are the wrong greeting. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
63 lines
2.3 KiB
PHP
63 lines
2.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Modules\Platform\Onboarding\InstallationWelcome;
|
|
use App\Modules\Platform\Updates\UpdateWelcome;
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
/**
|
|
* Takes the administrator to whichever page is waiting for them: the
|
|
* getting-started list on a new installation, or the what's-new page the
|
|
* first time they arrive after an update.
|
|
*
|
|
* Attached to the dashboard alone rather than to the whole web group.
|
|
* The dashboard is where a login lands and where the sidebar's logo
|
|
* points, so it catches the arrival either way — including the common
|
|
* case on a self-hosted server, where the person who ran update.sh was
|
|
* already signed in and never logs in at all. Applying it to every
|
|
* request instead would mean intercepting somebody mid-download or
|
|
* mid-upload to congratulate them, which is a worse trade than missing
|
|
* an administrator who happens to bookmark /files.
|
|
*
|
|
* One middleware for both because they are the same interruption, and a
|
|
* second one on the same route would have to know about the first to
|
|
* avoid arguing with it. Installation wins: the two cannot both be
|
|
* waiting in practice — an update marker is only raised for an
|
|
* installation that already existed — but if they ever were, somebody
|
|
* who has just installed this does not need release notes for a version
|
|
* they never ran.
|
|
*/
|
|
class RedirectToGreeting
|
|
{
|
|
public function __construct(
|
|
private readonly InstallationWelcome $installation,
|
|
private readonly UpdateWelcome $update,
|
|
) {}
|
|
|
|
public function handle(Request $request, Closure $next): Response
|
|
{
|
|
// GET only: a redirect swallows a POST body, and nothing that
|
|
// writes should ever be answered with a greeting.
|
|
if ($request->isMethod('GET')) {
|
|
$user = $request->user();
|
|
|
|
if ($user !== null) {
|
|
if ($this->installation->isWaitingFor($user)) {
|
|
return redirect()->route('system.getting-started');
|
|
}
|
|
|
|
if ($this->update->isWaitingFor($user)) {
|
|
return redirect()->route('system.whats-new');
|
|
}
|
|
}
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|