summaryrefslogtreecommitdiff
path: root/intern.gospeladlershof.de/code/check_login.php
blob: d06b357b21fa21d8c1036e9c9299a30666388024 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?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 && $hash != "" && $correct_hash != "" ) {
	$_SESSION["login"] = true;
	$_SESSION["success"] = "Erfolgreich eingeloggt.";
	$_SESSION["user"] = $mail;

	$_SESSION["dontdisplaydeploybutton"] = 1;

	$redis->del($mail);

	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");
}