Datenschutz-Einwilligung und externe Inhalte absichern
This commit is contained in:
parent
bdd3a86edb
commit
c37dc18b3e
29 changed files with 1662 additions and 34 deletions
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace App\Controllers;
|
||||
|
||||
use App\Core\Auth;
|
||||
use App\Core\Privacy;
|
||||
use App\Models\User;
|
||||
|
||||
class AuthController
|
||||
|
|
@ -215,6 +216,8 @@ class AuthController
|
|||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
Privacy::adoptGuestConsent((int) $user->id);
|
||||
|
||||
Auth::login($user);
|
||||
|
||||
redirect('/');
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class HomeController
|
|||
|
||||
// Führende/abschließende Anführungszeichen entfernen (wie im Original)
|
||||
$content = rtrim(ltrim($content, '"'), '"');
|
||||
$content = privacy_filter_embeds($content);
|
||||
|
||||
view('home', ['content' => $content]);
|
||||
}
|
||||
|
|
@ -25,7 +26,7 @@ class HomeController
|
|||
{
|
||||
$page = Page::byName('activities');
|
||||
|
||||
view('activities', ['content' => $page->content ?? '']);
|
||||
view('activities', ['content' => privacy_filter_embeds($page->content ?? '')]);
|
||||
}
|
||||
|
||||
public function meetings(): void
|
||||
|
|
|
|||
79
motorradig/src/Controllers/PrivacyController.php
Normal file
79
motorradig/src/Controllers/PrivacyController.php
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Core\Privacy;
|
||||
|
||||
class PrivacyController
|
||||
{
|
||||
public function show(): void
|
||||
{
|
||||
view('privacy', [
|
||||
'state' => Privacy::state(),
|
||||
'privacyError' => flash_pull('privacy_error'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function imprint(): void
|
||||
{
|
||||
view('imprint');
|
||||
}
|
||||
|
||||
public function storeConsent(): void
|
||||
{
|
||||
$returnTo = Privacy::returnPath('/');
|
||||
$alreadyAccepted = Privacy::accepted();
|
||||
|
||||
if (!$alreadyAccepted && input('privacy_notice') !== '1') {
|
||||
flash_set('privacy_error', 'Bitte bestätige die Datenschutzhinweise, bevor du fortfährst.');
|
||||
redirect($returnTo);
|
||||
}
|
||||
|
||||
$mode = (string) input('consent_mode', 'essential');
|
||||
$externalMedia = $mode === 'all' && input('external_media') === '1';
|
||||
|
||||
if (!Privacy::store($externalMedia)) {
|
||||
flash_set('privacy_error', 'Die Einwilligung konnte nicht gespeichert werden. Bitte versuche es erneut.');
|
||||
redirect($returnTo);
|
||||
}
|
||||
|
||||
flash_set('privacy_status', $externalMedia
|
||||
? 'Danke! Deine Einwilligung wurde gespeichert. Externe Inhalte dürfen geladen werden.'
|
||||
: 'Danke! Deine Einwilligung wurde gespeichert. Externe Inhalte bleiben deaktiviert.');
|
||||
|
||||
redirect($returnTo);
|
||||
}
|
||||
|
||||
public function updateExternalMedia(): void
|
||||
{
|
||||
if (!Privacy::accepted()) {
|
||||
redirect('/datenschutz');
|
||||
}
|
||||
|
||||
$returnTo = Privacy::returnPath('/datenschutz#externe-inhalte');
|
||||
$allowed = input('external_media') === '1';
|
||||
|
||||
if (!Privacy::setExternalMedia($allowed)) {
|
||||
flash_set('privacy_error', 'Die Einstellung konnte nicht gespeichert werden. Bitte versuche es erneut.');
|
||||
} else {
|
||||
flash_set('privacy_status', $allowed
|
||||
? 'Externe Inhalte (Google Maps, YouTube) sind jetzt erlaubt.'
|
||||
: 'Externe Inhalte (Google Maps, YouTube) sind jetzt deaktiviert.');
|
||||
}
|
||||
|
||||
redirect($returnTo);
|
||||
}
|
||||
|
||||
public function revoke(): void
|
||||
{
|
||||
if (!Privacy::revoke()) {
|
||||
flash_set('privacy_error', 'Die Einwilligung konnte nicht widerrufen werden. Bitte versuche es erneut.');
|
||||
redirect('/datenschutz');
|
||||
}
|
||||
|
||||
flash_set('privacy_status', 'Deine Einwilligung wurde widerrufen. Du kannst sie auf dieser Seite erneut erteilen.');
|
||||
redirect('/datenschutz');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue