-
Notifications
You must be signed in to change notification settings - Fork 2
/
forgottenPassword.php
42 lines (33 loc) · 1.24 KB
/
forgottenPassword.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
42
<?php
/**
* @author James Baster <[email protected]>
* @copyright City of Edinburgh Council & James Baster
* @license Open Source under the 3-clause BSD License
* @url https://github.com/City-Outdoors/City-Outdoors-Web
*/
require 'includes/src/global.php';
$currentUser = getCurrentUser();
if ($currentUser) {
header("Location: /");
die();
}
$tpl = getSmarty();
if (isset($_POST) && isset($_POST['email']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$user = User::loadByEmail($_POST['email']);
if ($user) {
$tplEmail = getEmailSmarty();
$tplEmail->assign('user',$user);
$tplEmail->assign('code',$user->getForgottenPasswordCode());
$body = $tplEmail->fetch('forgottenpassword.email.txt');
//print ($body); die();
mail($user->getEmail(), "You wanted to reset your password?", $body, "From: ".$CONFIG->EMAILS_FROM);
} else {
$tplEmail = getEmailSmarty();
$tplEmail->assign('email',$_POST['email']);
$body = $tplEmail->fetch('forgottenpassword.notfound.email.txt');
//print ($body); die();
mail($_POST['email'], "You wanted to reset your password?", $body, "From: ".$CONFIG->EMAILS_FROM);
}
$tpl->assign('okMessage','Please check your email for more instructions.');
}
$tpl->display('forgottenPassword.htm');