-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathresetPassword.php
41 lines (32 loc) · 1.04 KB
/
resetPassword.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
<?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();
//----------------------------------- Load user, check code
$user = User::loadByID($_GET['id']);
if (!$user) die("No User");
if (!$user->checkForgottenPasswordCode($_GET['c'])) die('code wrong');
//--------------------------------------- Reset password?
if (isset($_POST['NewPassword1']) && $_POST['NewPassword1']) {
try {
$user->setNewPassword($_POST['NewPassword1'],$_POST['NewPassword2']);
logInUser($user);
header("Location: /");
} catch (Exception $e) {
$tpl->assign('errorMessage', $e->getMessage());
}
}
//--------------------------------------- Display Form
$tpl->assign('user', $user);
$tpl->assign('code', $_GET['c']);
$tpl->display('resetPassword.htm');