im profil kann ein nutzer nun seine daten exportieren. man kann seinen account löschen. nach 2 jahren werden inaktive accounts gelöscht, 1 monat vorher wird eine email geschickt. Hilfetexte und Legal Pages in der Guest PWA korrigiert und vom layout her optimiert (dark mode).
This commit is contained in:
@@ -6,10 +6,35 @@ use App\Models\LegalPage;
|
||||
use App\Support\ApiError;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use League\CommonMark\Environment\Environment;
|
||||
use League\CommonMark\Extension\Autolink\AutolinkExtension;
|
||||
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
|
||||
use League\CommonMark\Extension\Strikethrough\StrikethroughExtension;
|
||||
use League\CommonMark\Extension\Table\TableExtension;
|
||||
use League\CommonMark\Extension\TaskList\TaskListExtension;
|
||||
use League\CommonMark\MarkdownConverter;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class LegalController extends BaseController
|
||||
{
|
||||
protected MarkdownConverter $markdown;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$environment = new Environment([
|
||||
'html_input' => 'strip',
|
||||
'allow_unsafe_links' => false,
|
||||
]);
|
||||
|
||||
$environment->addExtension(new CommonMarkCoreExtension());
|
||||
$environment->addExtension(new TableExtension());
|
||||
$environment->addExtension(new AutolinkExtension());
|
||||
$environment->addExtension(new StrikethroughExtension());
|
||||
$environment->addExtension(new TaskListExtension());
|
||||
|
||||
$this->markdown = new MarkdownConverter($environment);
|
||||
}
|
||||
|
||||
public function show(Request $request, string $slug)
|
||||
{
|
||||
$locale = $request->query('lang', 'de');
|
||||
@@ -39,7 +64,7 @@ class LegalController extends BaseController
|
||||
}
|
||||
|
||||
$title = $page->title[$locale] ?? $page->title[$page->locale_fallback] ?? $page->title['de'] ?? $page->title['en'] ?? $page->slug;
|
||||
$body = $page->body_markdown[$locale] ?? $page->body_markdown[$page->locale_fallback] ?? reset($page->body_markdown);
|
||||
$body = $page->body_markdown[$locale] ?? $page->body_markdown[$page->locale_fallback] ?? reset($page->body_markdown) ?? '';
|
||||
|
||||
return response()->json([
|
||||
'slug' => $page->slug,
|
||||
@@ -48,6 +73,12 @@ class LegalController extends BaseController
|
||||
'locale' => $locale,
|
||||
'title' => $title,
|
||||
'body_markdown' => (string) $body,
|
||||
'body_html' => $this->convertMarkdownToHtml($body),
|
||||
])->header('Cache-Control', 'no-store');
|
||||
}
|
||||
|
||||
protected function convertMarkdownToHtml(string $markdown): string
|
||||
{
|
||||
return trim((string) $this->markdown->convert($markdown));
|
||||
}
|
||||
}
|
||||
|
||||
39
app/Http/Controllers/ProfileAccountController.php
Normal file
39
app/Http/Controllers/ProfileAccountController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Jobs\AnonymizeAccount;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ProfileAccountController extends Controller
|
||||
{
|
||||
public function destroy(Request $request): RedirectResponse
|
||||
{
|
||||
$confirmationWord = Str::upper(__('profile.delete.confirmation_keyword'));
|
||||
|
||||
$request->validate([
|
||||
'confirmation' => [
|
||||
'required',
|
||||
function ($attribute, $value, $fail) use ($confirmationWord) {
|
||||
if (Str::upper(trim((string) $value)) !== $confirmationWord) {
|
||||
$fail(__('profile.delete.validation', ['word' => $confirmationWord]));
|
||||
}
|
||||
},
|
||||
],
|
||||
]);
|
||||
|
||||
$user = $request->user();
|
||||
|
||||
abort_unless($user, 403);
|
||||
|
||||
if ($user->tenant?->anonymized_at) {
|
||||
return back()->with('status', __('profile.delete.already'));
|
||||
}
|
||||
|
||||
AnonymizeAccount::dispatch($user->id);
|
||||
|
||||
return redirect()->route('profile.index')->with('status', __('profile.delete.started'));
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\DataExport;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
@@ -43,6 +44,36 @@ class ProfileController extends Controller
|
||||
->values()
|
||||
->all();
|
||||
|
||||
$recentExports = $user->dataExports()
|
||||
->latest()
|
||||
->limit(5)
|
||||
->get()
|
||||
->map(fn ($export) => [
|
||||
'id' => $export->id,
|
||||
'status' => $export->status,
|
||||
'size' => $export->size_bytes,
|
||||
'expires_at' => optional($export->expires_at)->toIso8601String(),
|
||||
'created_at' => optional($export->created_at)->toIso8601String(),
|
||||
'download_url' => $export->isReady() && ! $export->hasExpired()
|
||||
? route('profile.data-exports.download', $export)
|
||||
: null,
|
||||
'error_message' => $export->error_message,
|
||||
]);
|
||||
|
||||
$pendingExport = $user->dataExports()
|
||||
->whereIn('status', [
|
||||
DataExport::STATUS_PENDING,
|
||||
DataExport::STATUS_PROCESSING,
|
||||
])
|
||||
->exists();
|
||||
|
||||
$lastReadyExport = $user->dataExports()
|
||||
->where('status', DataExport::STATUS_READY)
|
||||
->latest('created_at')
|
||||
->first();
|
||||
|
||||
$nextExportAt = $lastReadyExport?->created_at?->clone()->addDay();
|
||||
|
||||
return Inertia::render('Profile/Index', [
|
||||
'userData' => [
|
||||
'id' => $user->id,
|
||||
@@ -68,6 +99,11 @@ class ProfileController extends Controller
|
||||
] : null,
|
||||
] : null,
|
||||
'purchases' => $purchases,
|
||||
'dataExport' => [
|
||||
'exports' => $recentExports,
|
||||
'hasPending' => $pendingExport,
|
||||
'nextRequestAt' => $nextExportAt?->toIso8601String(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
58
app/Http/Controllers/ProfileDataExportController.php
Normal file
58
app/Http/Controllers/ProfileDataExportController.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Jobs\GenerateDataExport;
|
||||
use App\Models\DataExport;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ProfileDataExportController extends Controller
|
||||
{
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
abort_unless($user, 403);
|
||||
|
||||
$hasRecentExport = $user->dataExports()
|
||||
->whereIn('status', [DataExport::STATUS_PENDING, DataExport::STATUS_PROCESSING])
|
||||
->exists();
|
||||
|
||||
if ($hasRecentExport) {
|
||||
return back()->with('error', __('profile.export.messages.in_progress'));
|
||||
}
|
||||
|
||||
$recentReadyExport = $user->dataExports()
|
||||
->where('status', DataExport::STATUS_READY)
|
||||
->where('created_at', '>=', now()->subDay())
|
||||
->exists();
|
||||
|
||||
if ($recentReadyExport) {
|
||||
return back()->with('error', __('profile.export.messages.recent_ready'));
|
||||
}
|
||||
|
||||
$export = $user->dataExports()->create([
|
||||
'tenant_id' => $user->tenant_id,
|
||||
'status' => DataExport::STATUS_PENDING,
|
||||
]);
|
||||
|
||||
GenerateDataExport::dispatch($export->id);
|
||||
|
||||
return back()->with('status', __('profile.export.messages.started'));
|
||||
}
|
||||
|
||||
public function download(Request $request, DataExport $export)
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
abort_unless($user && $export->user_id === $user->id, 403);
|
||||
|
||||
if (! $export->isReady() || $export->hasExpired() || ! $export->path) {
|
||||
return back()->with('error', __('profile.export.messages.not_available'));
|
||||
}
|
||||
|
||||
return Storage::disk('local')->download($export->path, sprintf('fotospiel-data-export-%s.zip', $export->created_at?->format('Ymd') ?? now()->format('Ymd')));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user