Files
Lars StommerandClaude Opus 5 fd2a7f7ded Dienste wirklich anschließen: zentrale Steuerung statt folgenloser Schalter
Die Schalter aus Phase 3 schrieben nur in eine Tabelle, die niemand las.
Ein gesperrter Portal-Abgleich lief trotzdem weiter. Das ist behoben.

`App\Tenancy\TenantFeatures` ist die eine Stelle, die beantwortet, ob ein
Mandant einen Dienst hat. Sie wird an allen Wegen abgefragt, die zum Dienst
führen:

- `RolePolicy::allows()` – damit greift die Mandanten-Ebene in *jeder*
  Richtlinie des Admins. Die Rolle sagt, was ein Benutzer darf; der Dienst
  sagt, was der Mandant überhaupt hat. Keine Rolle wiegt einen gesperrten
  Dienst auf.
- `Channel::importsOccupations()` – Import und Scheduler.
- Der öffentliche iCal-Feed antwortet mit 404.
- `ProcessPortalMail` und `channels:fetch-mail` für den Postfach-Schnellweg.

`TenantServiceKey::isWired()` trennt Gebautes von Geplantem. Nur verdrahtete
Dienste erscheinen als Schalter; die drei KI-Dienste stehen als Hinweis da,
bis die Anwendung sie abfragt. Eigene API-Schlüssel sind aus dem Betreiber-
Formular verschwunden – sie gehören in den Admin des Mandanten, wenn es
soweit ist (A16).

Neu im Betreiber-Bereich: Seite „System" mit den Grenzen, die für alle
Mandanten gelten (aus der .env, bewusst nicht änderbar), der Mandantenliste
und dem Zugriffsprotokoll. Bisher war dort nur die Mandantenliste.

Die Migration schaltet jedem vorhandenen Mandanten die Portal-Dienste frei,
damit der Umbau laufenden Betrieb nicht stillschweigend stoppt.

240 Feature-Tests grün, davon fünf neue in `TenantServiceGateTest`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-24 09:14:10 +02:00

66 lines
1.6 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Policies;
use App\Enums\Permission;
use App\Models\User;
use App\Tenancy\TenantFeatures;
/**
* Grants every ability that the current membership includes. The operator counts as administrator
* of the landlord that is open. A new role is added on UserRole, not in each policy.
*/
abstract class RolePolicy
{
abstract protected function permission(): Permission;
public function viewAny(User $user): bool
{
return $this->allows($user);
}
public function view(User $user): bool
{
return $this->allows($user);
}
public function create(User $user): bool
{
return $this->allows($user);
}
public function update(User $user): bool
{
return $this->allows($user);
}
public function delete(User $user): bool
{
return $this->allows($user);
}
public function deleteAny(User $user): bool
{
return $this->allows($user);
}
public function reorder(User $user): bool
{
return $this->allows($user);
}
/**
* Both questions, in one place: the role says what this user may do, TenantFeatures says what the
* landlord has unlocked at all. An administrator of a landlord without the portal services does not
* reach the portal screens either – no role grants what the landlord does not have.
*/
protected function allows(User $user): bool
{
if (! $user->currentRole()?->grants($this->permission())) {
return false;
}
return app(TenantFeatures::class)->permits($this->permission());
}
}