-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreset.php
71 lines (46 loc) · 1.23 KB
/
reset.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
include("include/init.php");
login_ensure_loggedout();
if (! $GLOBALS['cfg']['enable_feature_password_retrieval']){
error_404();
}
$reset_code = get_str('reset');
if (! $reset_code){
# seriously, go away...
header("location: /");
exit();
}
$user = users_get_by_password_reset_code($reset_code);
if (! $user){
$smarty->assign('error_nouser', 1);
$smarty->display('page_reset.txt');
exit();
}
$smarty->assign('reset_code', $reset_code);
if (post_isset('done')){
$new_password1 = post_str('new_password1');
$new_password2 = post_str('new_password2');
if ((! $new_password1) || (! $new_password2)){
$smarty->assign('error_missing_password', 1);
$smarty->display('page_reset.txt');
exit();
}
if ($new_password1 !== $new_password2){
$smarty->assign('error_password_mismatch', 1);
$smarty->display('page_reset.txt');
exit();
}
if (! users_update_password($user, $new_password1)){
$smarty->assign('error_update_failed', 1);
$smarty->display('page_reset.txt');
exit();
}
users_purge_password_reset_codes($user);
$user = users_get_by_id($user['id']);
login_do_login($user, "/account?password=1");
exit();
}
#
# output
#
$smarty->display('page_reset.txt');