aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates
diff options
context:
space:
mode:
authorwinter2024-12-31 22:30:16 +0000
committerwinter2024-12-31 22:31:26 +0000
commit4cd7017da9a37e5b9f38c3f50dd1c904ea41cbcb (patch)
treed77f1fd223dae44f40b22c9810aeba238733310d /templates
parent982e6213622bcb78a40d17f54cda27225a1d84b3 (diff)
implement user accounts and login
Diffstat (limited to 'templates')
-rw-r--r--templates/actor_avatar.php9
-rw-r--r--templates/login_form.php20
-rw-r--r--templates/login_page.php4
-rw-r--r--templates/skeleton.php13
4 files changed, 42 insertions, 4 deletions
diff --git a/templates/actor_avatar.php b/templates/actor_avatar.php
index d428006..439072b 100644
--- a/templates/actor_avatar.php
+++ b/templates/actor_avatar.php
@@ -1,4 +1,5 @@
-<picture class="avatar">
- <source srcset="<?= $actor->avatar ?>">
- <img src="/static/default-avatar.svg">
-</picture> \ No newline at end of file
+<?php if (isset($actor->avatar)): ?>
+ <img class="avatar" src="<?= $actor->avatar ?>">
+<?php else: ?>
+ <img class="avatar" src="/static/default-avatar.svg">
+<?php endif; ?> \ No newline at end of file
diff --git a/templates/login_form.php b/templates/login_form.php
new file mode 100644
index 0000000..2c32164
--- /dev/null
+++ b/templates/login_form.php
@@ -0,0 +1,20 @@
+<form method="post" hx-post="" hx-swap="outerHTML" hx-disabled-elt="find button">
+ <div class="row">
+ <label for="emailInput"><?= __('login.email') ?></label>
+ <input type="email" id="emailInput" name="email" value="<?= $email ?>" required>
+ </div>
+ <div class="row">
+ <label for="passwordInput"><?= __('login.password') ?></label>
+ <input type="password" id="passwordInput" name="password" required>
+ </div>
+ <div class="row">
+ <input type="checkbox" id="rememberMeInput" name="rememberSession">
+ <label for="rememberMeInput"><?= __('login.rememberMe') ?></label>
+ </div>
+ <div class="row">
+ <button><?= __('login.action') ?></button>
+ </div>
+ <?php if ($failed ?? false): ?>
+ <p class="error"><?= __('login.failed') ?></p>
+ <?php endif; ?>
+</form> \ No newline at end of file
diff --git a/templates/login_page.php b/templates/login_page.php
new file mode 100644
index 0000000..338330e
--- /dev/null
+++ b/templates/login_page.php
@@ -0,0 +1,4 @@
+<?php call_template('skeleton', ['pageTitle' => __('login.pageTitle')], function () {
+ global $email, $failed;
+ call_template('login_form', ['email' => $email, 'failed' => $failed]);
+}); \ No newline at end of file
diff --git a/templates/skeleton.php b/templates/skeleton.php
index 0d8afb4..94bc2f2 100644
--- a/templates/skeleton.php
+++ b/templates/skeleton.php
@@ -1,3 +1,6 @@
+<?php
+$user = Digitigrade\Model\UserAccount::findByCurrentSession();
+?>
<!DOCTYPE html>
<html lang="en">
@@ -18,6 +21,16 @@
<li><a href="/feed/local"><?= __('timeline.local.shortName') ?></a></li>
</ul>
<span id="siteTitle"><?= __('digitigrade') ?></span>
+ <?php if ($user == null): ?>
+ <ul>
+ <li><a href="/login"><?= __('navigation.login') ?></a></li>
+ </ul>
+ <?php else: ?>
+ <div>
+ <?php call_template('actor_avatar', ['actor' => $user->actor]) ?>
+ <?= $user->actor->displayName ?>
+ </div>
+ <?php endif; ?>
</nav>
</header>
<main>