-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResetPassword.php
60 lines (49 loc) · 1.65 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
require_once 'Include/Load.php';
$session = App::getSession();
$user = App::getUser();
$link = App::getDatabase();
$validator = App::getValidator();
if ($user->has('id') && $user->has('token')){
$user_id = App::get('id');
$token = App::get('token');
$result = $link->query('SELECT * FROM users WHERE id = :id AND reset_token IS NOT NULL AND reset_token = :reset_token AND reset_at > DATE_SUB(NOW(), INTERVAL 30 MINUTE)', [
'id' => $user_id,
'reset_token' => $token
])->fetch();
if ($result) {
if ($validator->isPosted()) {
$result = $user->resetPassword($result, $_POST['new_password']);
if (is_array($result)) {
$session->setFlash('alert', implode(', ', $result));
} else {
$session->setFlash('success', 'Your Password has been successfully modified');
App::redirect('Account.php');
}
}
} else {
$session->setFlash('alert', 'This Token is not valid');
App::redirect('Login.php');
}
} else {
App::redirect('Login.php');
}
?>
<?php require_once 'Include/Header.php' ?>
<div class="login-box">
<h2>Reset Password</h2>
<form action="" method="post">
<div class="user-box">
<input type="password" name="new_password" required="">
<label>New Password</label>
</div>
<div class="user-box">
<input type="password" name="confirm_password" required="">
<label>Confirm Password</label>
</div>
<button type="submit">Submit</button>
</form>
</div>
<?php require_once 'Include/Mode.php'; ?>
</body>
</html>