modules/index/validate_token.php
defbfa55
 <?php
c208bd90
 /*
 This file belongs to the Webinterface of schokokeks.org Hosting
 
cf54502a
 Written 2008-2018 by schokokeks.org Hosting, namely
c208bd90
   Bernd Wurst <bernd@schokokeks.org>
   Hanno Böck <hanno@schokokeks.org>
 
 To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
 
2626dd47
 You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
c208bd90
 http://creativecommons.org/publicdomain/zero/1.0/
 
 Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
 */
 
f2550e90
 title("Passwort setzen");
defbfa55
 
 $show = 'token';
 
2626dd47
 if (isset($_REQUEST['customerno']) and isset($_REQUEST['token'])) {
     $customerno = (int) $_REQUEST['customerno'];
     $token = $_REQUEST['token'];
9086c9ad
 
2626dd47
     require_once('newpass.php');
     require_once('inc/security.php');
     if (validate_token($customerno, $token)) {
         $show = 'password';
         if (isset($_POST['password'])) {
             if ($_POST['password'] != $_POST['password2']) {
                 input_error("Die beiden Passwort-Eingaben stimmen nicht überein.");
             } elseif ($_POST['password'] == '') {
                 input_error("Es kann kein leeres Passwort gesetzt werden");
             } elseif (($result = strong_password($_POST['password'])) !== true) {
                 input_error("Das Passwort ist zu einfach ({$result})!");
             } else {
                 require_once('session/checkuser.php');
                 require_once('inc/base.php');
                 logger(LOG_INFO, "modules/index/validate_token", "pwrecovery", "customer »{$customerno}« set a new password");
                 set_customer_password($customerno, $_POST['password']);
                 success_msg('Das Passwort wurde gesetzt!');
                 set_customer_verified($customerno);
                 set_customer_lastlogin($customerno);
                 invalidate_customer_token($customerno);
                 $_SESSION['role'] = ROLE_CUSTOMER;
                 $_SESSION['customerinfo'] = get_customer_info($customerno);
                 title("Passwort gesetzt");
                 output('<p>Ihr neues Passwort wurde gesetzt, Sie können jetzt '.internal_link("index", "die Web-Oberfläche sofort benutzen").'.</p>');
                 $show = null;
             }
         }
     } else {
         input_error("Der eingegebene Code war nicht korrekt. Bitte benutzen Sie die Kopieren &amp; Einfügen-Operation!");
defbfa55
     }
 }
 
2626dd47
 if ($show == 'password') {
     output('<p>Bitte legen Sie jetzt Ihr neues Kunden-Passwort fest.</p>
defbfa55
   <form action="" method="post">
b2f2617a
   <p style="display: none"><input type="hidden" name="customerno" value="'.$customerno.'" />
   <input type="hidden" name="token" value="'.$token.'" /></p>
defbfa55
   <p><span class="login_label">Neues Passwort:</span> <input type="password" name="password" size="30" /></p>
   <p><span class="login_label">Bestätigung:</span> <input type="password" name="password2" size="30" /></p>
ec0c81a8
   <p><span class="login_label">&#160;</span> <input type="submit" value="Passwort setzen" /></p>
defbfa55
   </form>');
2626dd47
 } elseif ($show == 'token') {
     output('<p>Bitte geben Sie Ihre Kundennummer und den per E-Mail zugeschickten Code ein. Alternativ können sie den Link aus der E-Mail direkt aufrufen.</p>
defbfa55
   <form action="" method="post">
   <p><span class="login_label">Kundennummer:</span> <input type="text" name="customerno" size="30" /></p>
fa6baaae
   <p><span class="login_label">Code:</span> <input type="text" name="token" size="30" /></p>
ec0c81a8
   <p><span class="login_label">&#160;</span> <input type="submit" value="Überprüfen" /></p>
defbfa55
   </form>');
 }