mirror of
https://github.com/projectsend/projectsend.git
synced 2026-09-16 16:45:07 +00:00
623ad686da
A managed installation's staff accounts were expected to arrive from outside it, so users.manage was Community-only and /users, /roles and their API twins answered 404 there. The platform side spent a long document designing its way around that gate; opening it is cheaper than routing around it, and more honest about where the knowledge sits. The division that settles it is the one managed storage already uses. We do not manage a tenant's files from outside — a bucket is provisioned, a scoped credential handed over, and what goes in it is the tenant's business. Seats are the same kind of thing. A platform knows how many staff accounts it sold; it does not know whether Alice should be an Account Manager, and it certainly does not know where her files go when she leaves. Capacity is the platform's, occupancy is the tenant's, and the cap belongs in an environment variable rather than in a closed screen. The capability stays in front of the routes rather than being deleted. It is currently true in both editions, but it is the seam an edition difference has to travel through, and removing it would mean inventing one again later. Seven test files asserted the old rule, which is the tests doing their job. Most flip. Two needed a different example instead: EnsureCapability and AbilityCapability were both using users.manage to stand for "Community-only", so they now use storage.configure and manage_updates — keys that still are. Two rationales half-expired and say so rather than being quietly rewritten. CommentAuthors gave two reasons for being a setting rather than a permission; the first was that roles are uneditable on cloud, which stopped being true here, and the second — that `Everyone` includes anonymous visitors, who have no role to hold a key — was always the stronger and is now the whole of it. The seat cap this makes necessary is the next commit, not this one. On its own this change lets a managed tenant create staff accounts without limit, which is why the two belong in the same release.
57 lines
1.8 KiB
PHP
57 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Modules\Comments;
|
|
|
|
use App\Modules\Identity\UserType;
|
|
|
|
/**
|
|
* Who may write a comment (Setting::CommentsAuthors).
|
|
*
|
|
* This is a setting rather than a permission on purpose, and one of the
|
|
* two reasons has since expired. It used to be that roles were editable
|
|
* only in the community edition — the cloud edition gated the whole roles
|
|
* screen behind Capability::UsersManage — so a permission key would have
|
|
* been unconfigurable for half our installs. That stopped being true in
|
|
* 2.2.0, when users.manage opened on both editions.
|
|
*
|
|
* The reason that carries it now is the one a permission structurally
|
|
* cannot express: `Everyone` includes anonymous visitors, who have no
|
|
* account and therefore no role to hold a key. That was always the
|
|
* stronger half; it is now the whole of it.
|
|
*/
|
|
enum CommentAuthors: string
|
|
{
|
|
case Staff = 'staff';
|
|
case Clients = 'clients';
|
|
case StaffAndClients = 'staff_and_clients';
|
|
case Everyone = 'everyone';
|
|
|
|
/**
|
|
* @param UserType|null $type Null means an anonymous visitor.
|
|
*/
|
|
public function allows(?UserType $type): bool
|
|
{
|
|
return match ($this) {
|
|
self::Staff => $type === UserType::Staff,
|
|
self::Clients => $type === UserType::Client,
|
|
self::StaffAndClients => $type !== null,
|
|
self::Everyone => true,
|
|
};
|
|
}
|
|
|
|
/**
|
|
* English label — also the translation key.
|
|
*/
|
|
public function label(): string
|
|
{
|
|
return match ($this) {
|
|
self::Staff => 'Staff only',
|
|
self::Clients => 'Clients only',
|
|
self::StaffAndClients => 'Staff and clients',
|
|
self::Everyone => 'Anyone, including visitors who are not logged in',
|
|
};
|
|
}
|
|
}
|