Datenschutz: Tour-Galerien nur für Teilnehmer und Admins
- zentrale Regel Booking::canAccessTourGallery() (Buchung oder Admin) - Galerie-Ansicht und Upload nutzen diese Regel - Bild-Auslieferung prüft die Kategorie: Tour-Bilder nur für Teilnehmer, Papierkorb nur für Admins, unbekannte Kategorien gesperrt - unberechtigte Bild-Requests liefern HTTP 403 statt Inhalt - Bilder mit Cache-Control private/must-revalidate und ETag/304 - MIME-Typ wird am Bildinhalt ermittelt (Platzhalter war JPEG als .png) - öffentlichen Link auf ein geschütztes Tour-Bild von der Startseite entfernt
This commit is contained in:
parent
afdb77549a
commit
3570f6a8ed
5 changed files with 125 additions and 16 deletions
|
|
@ -15,6 +15,23 @@ class Booking extends Model
|
|||
return (int) db()->fetchValue('SELECT COUNT(*) FROM `bookings` WHERE tour_id = ?', [$tourId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* true, wenn der Benutzer die Bildergalerie einer Tour sehen darf:
|
||||
* Admins immer, sonst nur Teilnehmer (vorhandene Buchung).
|
||||
*/
|
||||
public static function canAccessTourGallery(int $tourId, ?User $user): bool
|
||||
{
|
||||
if ($user === null || $tourId <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($user->isAdmin()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return static::forUser($tourId, (int) $user->id) !== null;
|
||||
}
|
||||
|
||||
public static function forUser(int $tourId, int $userId): ?static
|
||||
{
|
||||
$row = db()->fetchOne('SELECT * FROM `bookings` WHERE tour_id = ? AND user_id = ?', [$tourId, $userId]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue