-
Notifications
You must be signed in to change notification settings - Fork 0
/
changepassword.php
97 lines (83 loc) · 2.53 KB
/
changepassword.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
require_once 'core/init.php';
$user = new User();
if($user->hasPermission('banned')){
exit("you are banned");
}
if(!$user->isLoggedIn()){
Redirect::to('index.php');
exit('
<div id="container">
<div class="form-main">
<div class="red loginBar" > You need to login in or register</div>
<div class="form-div">
<a href="register.php" class="trans button grey"> Register</a>
<a href="login.php" class="trans mLeft button green greenB" type="submit">Log In</a>
</div>
</div>
</div>');
}
include 'includes/header.php';
include 'includes/nav.php';
echo "<div style='display:none' class='warning red'></div>";
if(Input::exists()){
if(Token::check(Input::get('token'))){
$validate = new Validate();
$validation = $validate->check($_POST, array(
'password_current' => array(
'required' => true,
'min' => 6
),
'password_new' => array(
'required' =>true,
'min' => 6
),
'password_new_again' => array(
'required' => true,
'min' => 6,
'matches' => 'password_new'
)
));
if($validation->passed()){
if(Hash::make(Input::get('password_current'), $user->data()->salt) !== $user->data()->password){
echo 'your current password is wrong';
}else{
$salt = Hash::salt(32);
$user->update(array(
'password' => hash::make(Input::get('password_new'), $salt),
'salt' => $salt
));
Session::flash('home', ' your password has been changed!');
Redirect::to('index.php');
}
}else{
foreach($validation->errors() as $error){
echo "<div class='warning red'>$error</div>";
}
}
}
}
?>
<div class="wrap">
<div class="content">
<div class="contentCenter">
<div class="bar green">
<h1>Change Password</h1>
</div>
<form action="" method="post">
<div class="form-div">
<label class="formLable" for="password_current">Current password</label>
<input class="password feedback-input" type="password" name="password_current" id="password_current" required>
<label class="formLable" for="password_new">New password</label>
<input class="password feedback-input" type="password" name="password_new" id="password_new" required>
<label class="formLable" for="password_new_again">New password again</label>
<input class="password feedback-input" type="password" name="password_new_again" id="password_new_again" required>
<input type="hidden" name="token" value="<?php echo Token::generate(); ?>">
<input class="button green greenB" type="submit" value="Change">
</div>
</form>
</div>
</div>
</div>
</body>
</html>