forked from WWBN/AVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
userRecoverPassSave.json.php
30 lines (30 loc) · 1.14 KB
/
userRecoverPassSave.json.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
<?php
header('Content-Type: application/json');
global $global, $config;
if(!isset($global['systemRootPath'])){
require_once '../videos/configuration.php';
}
require_once $global['systemRootPath'] . 'objects/user.php';
$obj = new stdClass();
if (empty($_POST['user']) || empty($_POST['recoverPassword']) || empty($_POST['newPassword']) || empty($_POST['newPasswordConfirm'])) {
$obj->error = __("There is missing data to recover your password");
die(json_encode($obj));
}
$user = new User(0, $_POST['user'], false);
if (empty($user)) {
$obj->error = __("User not found");
die(json_encode($obj));
} elseif ($user->getRecoverPass() !== $_POST['recoverPassword']) {
$obj->error = __("Recover password does not match");
die(json_encode($obj));
} elseif ($_POST['newPassword'] !== $_POST['newPasswordConfirm']) {
$obj->error = __("Confirmation password does not match");
die(json_encode($obj));
} else {
$user->setPassword($_POST['newPassword']);
$user->setRecoverPass(uniqid(), true);
if ($user->save()) {
$obj->success = __("Your Password has been set");
die(json_encode($obj));
}
}