diff --git a/public/profile.php b/public/profile.php index 3184ac79..bc3bca12 100644 --- a/public/profile.php +++ b/public/profile.php @@ -3,7 +3,14 @@ use Misuzu\Users\User; require_once __DIR__ . '/../misuzu.php'; -$user_id = (int)$_GET['u']; +$user_id = (int)($_GET['u'] ?? 0); + +try { + $app->templating->vars(['profile' => User::findOrFail($user_id)]); +} catch (Exception $ex) { + http_response_code(404); + echo $app->templating->render('user.notfound'); + return; +} -$app->templating->vars(['profile' => User::findOrFail($user_id)]); echo $app->templating->render('user.view'); diff --git a/views/mio/user/notfound.twig b/views/mio/user/notfound.twig new file mode 100644 index 00000000..1482a3ad --- /dev/null +++ b/views/mio/user/notfound.twig @@ -0,0 +1,15 @@ +{% extends '@mio/user/master.twig' %} +{% from '@mio/macros.twig' import navigation %} + +{% set title = 'User not found!' %} + +{% block content %} +
+
User not found!
+
+

Check the url and try again.

+
+
+ + {{ navigation(mio_navigation, false) }} +{% endblock %}