git.shiar.nl
/
minimedit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
39cb639
)
login: show user after login; explicit option for logout
author
Mischa POSLAWSKY
<perl@shiar.org>
Sun, 17 Sep 2017 00:46:13 +0000
(
02:46
+0200)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Mon, 2 Oct 2017 20:50:29 +0000
(22:50 +0200)
login.php
patch
|
blob
|
history
diff --git
a/login.php
b/login.php
index c9a60e3ed4eefa4870a54060dfc481e11ec943a2..bcb1edc44cd709a9f9e1bc4b1c6931ee46621946 100644
(file)
--- a/
login.php
+++ b/
login.php
@@
-1,25
+1,41
@@
<?php
if (isset($_POST['login'])) {
<?php
if (isset($_POST['login'])) {
- if ($user = login($_POST['login'], $_POST['pass'])) {
- setcookie('login', $user['auth'], 0, '/');
-
- ob_clean();
- $target = ltrim(@$_GET['goto'], '/');
- header("Location: /$target");
- http_response_code(302);
- exit;
+ if ($User = login($_POST['login'], $_POST['pass'])) {
+ setcookie('login', $User['auth'], 0, '/');
+ }
+ else {
+ echo '<p class="warn">Ongeldige gebruikersnaam of wachtwoord.</p>'."\n\n";
}
}
-
- echo '<p class="warn">Ongeldige gebruikersnaam of wachtwoord.</p>'."\n\n";
}
}
-elseif (
!empty($User
)) {
+elseif (
isset($_GET['logout']
)) {
setcookie('login', '', time(), '/'); # expire immediately
setcookie('login', '', time(), '/'); # expire immediately
+ $User = NULL;
echo '<p class="warn">Uitgelogd.</p>'."\n\n";
}
echo '<p class="warn">Uitgelogd.</p>'."\n\n";
}
+if (isset($_GET['goto']) and isset($User)) {
+ ob_clean();
+ $target = ltrim($_GET['goto'], '/');
+ header("Location: /$target");
+ http_response_code(302);
+ exit;
+}
+
+if (empty($User)) {
?>
<form action="" method="post">
<input id="login" name="login" placeholder="Huisnummer" />
<input id="pass" name="pass" type="password" value="" placeholder="Wachtwoord" />
<input type="submit" value="Log in" />
</form>
?>
<form action="" method="post">
<input id="login" name="login" placeholder="Huisnummer" />
<input id="pass" name="pass" type="password" value="" placeholder="Wachtwoord" />
<input type="submit" value="Log in" />
</form>
+<?php
+ return;
+}
+
+ob_clean();
+?>
+<h2>Ingelogd</h2>
+
+<p>Ingelogd als <em><?php print $User['name']; ?></em>.</p>
+
+<p class="nav"><a href="?logout">Uitloggen</a></p>