diff --git a/fn/common.php b/fn/common.php
index 8b08708..4a4700e 100644
--- a/fn/common.php
+++ b/fn/common.php
@@ -76,3 +76,13 @@ function redirUrl($pageId) {
if (PAGE !== 'index') $currentPath .= PAGE;
return CONF['common']['prefix'] . "/$pageId?redir=$currentPath";
}
+
+function redir() {
+ if (isset($_GET['redir'])) {
+ if (preg_match('/^[0-9a-z\/-]{0,128}$/', $_GET['redir']) !== 1)
+ userError("Wrong character in redir
.");
+ header('Location: ' . CONF['common']['prefix'] . '/' . $_GET['redir']);
+ } else {
+ header('Location: ' . CONF['common']['prefix'] . '/');
+ }
+}
diff --git a/public/auth/login.php b/public/auth/login.php
index 15c9c6f..539f08e 100644
--- a/public/auth/login.php
+++ b/public/auth/login.php
@@ -33,12 +33,6 @@ $_SESSION['username'] = $_POST['username'];
if (outdatedPasswordHash($_SESSION['username']))
changePassword($_SESSION['username'], $_POST['password']);
-if (isset($_GET['redir'])) {
- if (preg_match("/^[0-9a-z\/-]+$/", $_GET['redir']) !== 1)
- userError("Wrong character in redir
.");
- header("Location: " . CONF['common']['prefix'] . "/" . $_GET['redir']);
-} else {
- header("Location: " . CONF['common']['prefix'] . "/");
-}
+redir();
success("Connecté·e.");
diff --git a/public/auth/logout.php b/public/auth/logout.php
index fce9780..6d381dc 100644
--- a/public/auth/logout.php
+++ b/public/auth/logout.php
@@ -6,5 +6,5 @@ if (session_status() === PHP_SESSION_ACTIVE)
session_destroy();
header('Clear-Site-Data: "*"');
-header('Location: ' . CONF['common']['prefix'] . '/');
+redir();
success("Déconnecté·e.");
diff --git a/public/auth/register.php b/public/auth/register.php
index 303bbf6..14f1180 100644
--- a/public/auth/register.php
+++ b/public/auth/register.php
@@ -52,6 +52,6 @@ $stmt->execute();
$_SESSION['username'] = $_POST['username'];
-header('Location: ' . CONF['common']['prefix'] . '/');
+redir();
success("Compte créé.");