Auth logic is completed (signin, signup, logout), Added: Middlewares, RequireAuth middleware

This commit is contained in:
2024-12-26 14:44:40 +01:00
parent 01b057986e
commit 4c44dac115
11 changed files with 112 additions and 31 deletions

View File

@ -1,9 +1,21 @@
<section class="signin">
<form>
<label for="username">Username</label>
<input type="text" name="username" id="username">
<label for="password">Password</label>
<input type="password" name="password" id="password">
<input type="submit" value="Sign In" id="submit-signin">
</form>
<?php if ($this->get('error')): ?>
<div class="error"><?= $this->get('error') ?></div>
<?php endif; ?>
<form action="/auth/signin" method="POST">
<label for="email">Email</label>
<input type="email" name="email" id="email" value="<?= htmlspecialchars($_POST['email'] ?? '') ?>" required>
<?php if (isset($this->get('validationErrors')['email'])): ?>
<small class="error"><?= $this->get('validationErrors')['email'] ?></small>
<?php endif; ?>
<label for="password">Password</label>
<input type="password" name="password" id="password" required>
<?php if (isset($this->get('validationErrors')['password'])): ?>
<small class="error"><?= $this->get('validationErrors')['password'] ?></small>
<?php endif; ?>
<input type="submit" value="Sign In">
</form>
</section>

View File

@ -0,0 +1 @@
<h1>Welcome <?= $_SESSION['user']['username']?>!</h1>

View File

@ -8,6 +8,7 @@
<header>
<a href="/auth/signin">Log In</a>
<a href="/auth/signup">Sign Up</a>
<a href="/auth/logout">Log Out</a>
</header>
<section class="content">
<?= $content ?>

View File

@ -1,4 +0,0 @@
<header>
<a href="/signin">Log In</a>
<a href="/signup">Sign Up</a>
</header>