summaryrefslogtreecommitdiff
path: root/intern.gospeladlershof.de/code/check_login.php
diff options
context:
space:
mode:
Diffstat (limited to 'intern.gospeladlershof.de/code/check_login.php')
-rw-r--r--intern.gospeladlershof.de/code/check_login.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/intern.gospeladlershof.de/code/check_login.php b/intern.gospeladlershof.de/code/check_login.php
new file mode 100644
index 0000000..0ea8ecd
--- /dev/null
+++ b/intern.gospeladlershof.de/code/check_login.php
@@ -0,0 +1,37 @@
+<?php
+
+define("LOGIN_SITE", true);
+require_once __DIR__ . '/session.php';
+require_once __DIR__ . '/../vendor/autoload.php';
+
+$mail = strtolower($_REQUEST["email"]);
+$hash = $_REQUEST["hash"];
+
+$redis = new Predis\Client([
+ 'scheme' => 'tcp',
+ 'host' => '192.168.122.1',
+ 'port' => 6379,
+ 'database' => 2,
+]);
+
+$correct_hash = $redis->get($mail);
+
+if ( $hash === $correct_hash ) {
+ $_SESSION["login"] = true;
+ $_SESSION["success"] = "Erfolgreich eingeloggt.";
+ $_SESSION["user"] = $mail;
+
+ $_SESSION["dontdisplaydeploybutton"] = 1;
+
+ header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect");
+ header("Location: /");
+
+ exit;
+} else {
+
+ $_SESSION["login"] = false;
+ $_SESSION["error"] = "Entweder kennen wir deine E-Mail nicht oder du hast den Code falsch kopiert.";
+
+ header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect");
+ header("Location: /login.php");
+}