-
Notifications
You must be signed in to change notification settings - Fork 1
/
send_new_password.php
41 lines (34 loc) · 1.31 KB
/
send_new_password.php
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
40
41
<?php
require_once('runtime.php');
require_once(ROOT_DIR.'/lib/core/helper.class.php');
require_once(ROOT_DIR.'/lib/core/register.class.php');
require_once(ROOT_DIR.'/lib/core/user_old.class.php');
require_once(ROOT_DIR.'/lib/extern/phpass/PasswordHash.php');
$Register = new Register;
if (empty($_POST['email'])) {
$smarty->assign('message', Message::getMessage());
$smarty->display("header.tpl.html");
$smarty->display("send_new_password.tpl.html");
$smarty->display("footer.tpl.html");
} else {
$user_data = User_old::getUserByEmail($_POST['email']);
if ($user_data) {
$new_password = Helper::randomPassword(10);
//hash password to store in db
$phpass = new PasswordHash(8, false);
$new_password_hash = $phpass->HashPassword($new_password);
if (strlen($new_password_hash) < 20) {
$message[] = array("Beim Hashen des Passworts trat ein Fehler auf.",2);
Message::setMessage($message);
header('Location: ./login.php');
die();
}
$Register->sendPassword($user_data['id'], $user_data['email'], $user_data['nickname'], $new_password, $new_password_hash, $user_data['password']);
header('Location: ./login.php');
} else {
$message[] = array("Die Emailadresse konnte keinem Benutzer zugeordnet werden.", 2);
Message::setMessage($message);
header('Location: ./send_new_password.php');
}
}
?>