-
Notifications
You must be signed in to change notification settings - Fork 2
/
reset_password.php
164 lines (124 loc) · 4.68 KB
/
reset_password.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php include('inc/header.php'); ?>
<?php
if ( isset($_GET['code'])){
$code=$_GET['code'];
$disabled="disabled";
}
else{
$code="";
$disabled="";
}
?>
<div class="box-bg" style="background-color:#f7f7f7;">
<div class="container">
<div class="row" style="height:70vh; margin-top:8%;">
<div class="col-md-4 col-sm-offset-4 col-md-offset-4">
<a href="recoverAccount.php" style="display:block; text-align:center;">Resend reset instruction to my email again</a>
<div class="panel panel-primary" style="margin-top:3%;">
<div class="panel-heading">
<h3 class="panel-title text-center">Change your password</h3>
</div>
<div class="panel-body">
<form class="chPass" id="chPass" role="form" method="post">
<?php
if ( ! isset($_GET['code'])){
?>
<p class="text-center">Please type verification code.</p>
<hr>
<div class="form-group">
<input type="text" name="verification_code" class="verification_code form-control" placeholder="Verification code">
</div>
<p class="text-center">AND</p>
<?php }?>
<p class="text-center">Enter your new password below to complete the process.</p>
<hr>
<div class="form-group">
<input type="password" name="password1" class="password1 form-control" placeholder="Password">
</div>
<div class="form-group">
<input type="password" name="password2" class="password2 form-control" placeholder="Retype password">
</div>
<div class="form-group">
<button style="width: 100%;" type="submit" name="login-btn" id="loginBtn" class="pull-rigth btn btn-primary">Save changes & login</button>
</div>
</div>
</form>
</div>
</div>
<div class="col-sm-12 col-md-12">
<a href="index.php" style="display:block; text-align:center;">Back to Home <i class="fa fa-home"> </i></a>
</div>
</div>
</div>
</div>
<?php include('inc/footer.php'); ?>
<script>
$( function(){
$('#chPass').submit( function(e){
e.preventDefault();
//var formData =$(this).serialize();
var verv="";
<?php
if ( ! isset($_GET['code'])){
?>
var ver=$('#chPass .verification_code');
verv=$('#chPass .verification_code').val();
if(! minMax_a(4, 20, ver, "Please enter your verification code below")){
return false;
}
<?php
}
else{
?>
verv='<?php echo $code; ?>';
<?php
}
?>
var pass1=$('#chPass .password1');
var pass1v=$('#chPass .password1').val();
var pass2=$('#chPass .password2');
var pass2v=$('#chPass .password2').val();
//validating class
if(! minMax_a(4, 20, pass1, "Please enter your password below")){
return false;
}
else if(! minMax_a(4, 20, pass2, "Please Confirm your password below")){
return false;
}
else if(pass1v!=pass2v){
notify("Passwords did not match please retype it","error");
//pass1.val("");
pass2.val("");
return false;
}
var sendData={
"code":verv,
"account_type":"sponsor",
"pass1":pass1v,
"pass2":pass2v
}
var chPassSettings={
"type":"POST",
"dataType":"json",
"url":'api/settings/password/reset/complete',
"headers":{
"cache-control":"no-cache"
},
"data":sendData
};
$.ajax(chPassSettings).success(function(responseSub){
console.log(JSON.stringify(responseSub));
if(responseSub.status=="failed" || responseSub.status=="warning"){
notify("Sorry "+responseSub.message,"error");
}
else if(responseSub.status=="success" || responseSub.status=="success"){
notify("Hey your account password has been changed", "success");
window.location="index.php?action=login";
}
else{
notify("Sorry "+responseSub.message,"error");
}
});
});
});
</script>