From 5fd2250f7c9a5be373e5c71f50d0c1e001f80322 Mon Sep 17 00:00:00 2001 From: horus_arch Date: Mon, 20 Feb 2017 13:48:50 +0100 Subject: Testet Passwordless-Login. --- intern.gospeladlershof.de/check_login.php | 42 ++++ intern.gospeladlershof.de/code/check_login.php | 37 +++ intern.gospeladlershof.de/code/login.php | 79 ++++--- intern.gospeladlershof.de/code/send_email.php | 11 + .../code/template/html_mail.php | 250 +++++++++++++++++++++ .../code/template/text_mail.php | 10 + intern.gospeladlershof.de/login.php | 8 +- 7 files changed, 404 insertions(+), 33 deletions(-) create mode 100644 intern.gospeladlershof.de/check_login.php create mode 100644 intern.gospeladlershof.de/code/check_login.php create mode 100644 intern.gospeladlershof.de/code/send_email.php create mode 100644 intern.gospeladlershof.de/code/template/html_mail.php create mode 100644 intern.gospeladlershof.de/code/template/text_mail.php diff --git a/intern.gospeladlershof.de/check_login.php b/intern.gospeladlershof.de/check_login.php new file mode 100644 index 0000000..e812a99 --- /dev/null +++ b/intern.gospeladlershof.de/check_login.php @@ -0,0 +1,42 @@ + + + +
+ +
+ + + + + + + + Du hast einen Code aus der E-Mail enthalten. Trag ihn hier ein. + +
+ +
+ 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 @@ + '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"); +} diff --git a/intern.gospeladlershof.de/code/login.php b/intern.gospeladlershof.de/code/login.php index ba41b1c..002ddd3 100644 --- a/intern.gospeladlershof.de/code/login.php +++ b/intern.gospeladlershof.de/code/login.php @@ -2,45 +2,71 @@ define("LOGIN_SITE", true); require_once __DIR__ . '/session.php'; +require_once __DIR__ . '/../vendor/autoload.php'; +use Pheanstalk\Pheanstalk; -$mail = $_REQUEST["email"]; +$mail = strtolower($_REQUEST["email"]); $passwd = hash("sha512", $_REQUEST["password"]); $addresses= file(__DIR__ . "/../../intern/chor_list_members.txt", FILE_IGNORE_NEW_LINES); -if ( "2397be3187f0ab864802fbe2b6c3207a01328988d524973d4eeaa48928410a2588263882e37e68363691fd8d7c3c83e8ebe46166bee13404ae61484c13b55e1f" === $passwd || - "319e789e0fa1867bb08b197b306cc48aa0a109511f5e36dbdd1ed642cda8b7f222b0b6a31a43d2302d17562734d40eeb1f85cb99b4bf3101b3c7cef490d89ed2" === $passwd || - "bf3da3d012e3ed51eeae20f3d5e37e655dfb9a0a1bcf29fec7d9ff425547de2388d21a4395019e0d433beb1b7f5a9f730535ea85b2ba6de7eb0d84aafb76902a" === $passwd || - "373a3dd664c54f99059c4801f3807bdc16c4c22f208a05a5a3d8e990c3e76d4a96c27ebe6aa2b8db1ca02eee3d5e5a458dc5819e3852952f5b7d5f3e631b6fcf" === $passwd -) { +foreach($addresses as $a) { -/* -if ( $mail === "Chor" || "chor" === $mail ) { - $_SESSION["login"] = true; - $_SESSION["success"] = "Erfolgreich eingeloggt. Der Nutzername 'chor' wird bald deaktiviert. Bitte benutze deine E-Mail-Adresse als Login-Name."; + if ( $mail === strtolower($a) ) { + $hash = chr( mt_rand( 97 ,122 ) ) .substr( md5( time( ) ) ,1 ); + ob_start(); + require __DIR__ . '/template/html_mail.php'; + $htmlmessage = ob_get_clean(); - $_SESSION["dontdisplaydeploybutton"] = 1; - $_SESSION["user"] = $mail; + ob_start(); + require __DIR__ . 'template/text_mail.php'; + $textmessage = ob_get_clean(); - header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect"); - header("Location: /"); + $redis = new Predis\Client([ + 'scheme' => 'tcp', + 'host' => '192.168.122.1', + 'port' => 6379, + 'database' => 2, + ]); - exit; + $redis->set($mail, $hash, "ex", 86400); // hält den Wert für 24h + + $pheanstalk = new Pheanstalk('192.168.122.1'); + + $data = array( + 'To' => $mail, + 'Name' => 'Gospelchor Adlershof', + 'From' => 'noreply@gospeladlershof.de', + 'ReplyTo' => 'webmaster@gospeladlershof.de', + 'Subject' => 'Gospelchor Adlershof | Login', + 'HTMLMessage' => $htmlmessage, + 'TextMessage' => $textmessage, + ); + + $pheanstalk + ->useTube('contactme_mailer') + ->put(json_encode($data)); + + $_SESSION["user"] = $mail; + + error_log(json_encode($data)); + } } - */ - foreach($addresses as $a) { - if ( strtolower($mail) === strtolower($a) ) { - $_SESSION["login"] = true; - $_SESSION["success"] = "Erfolgreich eingeloggt."; - $_SESSION["dontdisplaydeploybutton"] = 1; - $_SESSION["user"] = $mail; +header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect"); +header("Location: /check_login.php"); + + /* + $_SESSION["login"] = true; + $_SESSION["success"] = "Erfolgreich eingeloggt."; + + $_SESSION["dontdisplaydeploybutton"] = 1; + $_SESSION["user"] = $mail; - header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect"); - header("Location: /"); + header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect"); + header("Location: /"); - exit; - } + exit; } } @@ -49,3 +75,4 @@ $_SESSION["error"] = "E-Mail oder Passwort stimmmen nicht überein."; header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect"); header("Location: /login.php"); + */ diff --git a/intern.gospeladlershof.de/code/send_email.php b/intern.gospeladlershof.de/code/send_email.php new file mode 100644 index 0000000..72cd25f --- /dev/null +++ b/intern.gospeladlershof.de/code/send_email.php @@ -0,0 +1,11 @@ +useTube('testtube') + ->put($data); diff --git a/intern.gospeladlershof.de/code/template/html_mail.php b/intern.gospeladlershof.de/code/template/html_mail.php new file mode 100644 index 0000000..0389e64 --- /dev/null +++ b/intern.gospeladlershof.de/code/template/html_mail.php @@ -0,0 +1,250 @@ + + + + + +Gospelchor Adlershof | Login + + + + + + + + + + + + +
+ + +
+ + + + +
+

Gospelchor Adlershof

+

Hallo,

+

um dich auf der Website des Gospelchors einzuloggen, folge bitte diesem Link:

+ + + + + +
+ Hier klicken um zur Website des Gospelchors zu kommen +
+ +

Der Link verfällt innerhalb 24h.

+

Sollte der Link nicht funktionieren, dein Authentifizierungscode lautet .

+ +

Viele Gr,
+ der Gospelchor

+

Website des Gospelchors

+

Archiv der Mailing Liste

+
+
+ + +
+ + + + + + + + + + + + + + diff --git a/intern.gospeladlershof.de/code/template/text_mail.php b/intern.gospeladlershof.de/code/template/text_mail.php new file mode 100644 index 0000000..7e67be7 --- /dev/null +++ b/intern.gospeladlershof.de/code/template/text_mail.php @@ -0,0 +1,10 @@ +Hallo, + +um dich auf der Webseite des Gospelchors einzuloggen, folge bitte diesem Link: +https://intern.gospeladlershof.de/code/check_login.php?email=&hash= + +Der Link verfällt innerhalb 24h. +Sollte der Link nicht funktionieren, dein Authentifizierungscode lautet . + +Viele Grüße, +der Gospelchor diff --git a/intern.gospeladlershof.de/login.php b/intern.gospeladlershof.de/login.php index c9462f1..23c2695 100644 --- a/intern.gospeladlershof.de/login.php +++ b/intern.gospeladlershof.de/login.php @@ -32,13 +32,7 @@ if ( ! empty($_SESSION) ) {

Bitte melde dich an

- - - + Es wird dir eine E-Mail an dieselbe Adresse geschickt, mit der du auch die anderen E-Mails des Chors liest. -- cgit v1.2.3