Commit 8f72160e by Teeradone-PIM

teeradone: change password

parent 03600516
......@@ -399,22 +399,15 @@ class UsersController extends AppController {
]
])->first();
if ($this->request->is('post')) {
$hasher = new DefaultPasswordHasher();
$password = $this->request->data['password'];
$confirm_password = $this->request->data['confirm_password'];
$oldpassword = $this->request->data['oldpassword'];
$this->request->data['password'] = $hasher->hash($this->request->data['password']);
//------- เทียบ password ที่เข้ารหัส ---------------password_verify($password,hashed_password)---------------------------
if (password_verify($oldpassword, $users['password'])) {
$users = $this->Users->patchEntity($users, $this->request->getData());
$this->Users->save($users);
$this->Flash->success(__('change password success'));
return $this->redirect(['action' => 'signin']);
} else {
$this->Flash->error(__('Invalid password.'));
return $this->redirect(['action' => 'change-password/'.$token]);
}
}
$this->set(array('token' => $token, '_serialize' => array('token')));
}
......
......@@ -8,14 +8,6 @@
</div>-->
<?php echo $this->Form->create(null, ['url' => ['controller' => 'Users','action' => 'changePassword/'.$token],'class' => 'form-horizontal','id' => '','name' => 'changePressword','role' => 'form', 'onsubmit' => 'return validateForm()']);?>
<?php echo $this->Flash->render(); ?>
<div>
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('รหัสผ่านเก่า');?></label>
<input type="password" value="" name="oldpassword" placeholder="********" class="form-control-reg border-bottom-from" id="oldpassword" onkeyup='check();'>
<span class="glyphicon glyphicon-eye-close form-control-feedback" id='message'></span>
</div>
</div>
</div>
<div>
<div class="form-group has-feedback">
......@@ -54,16 +46,6 @@
<script>
function validateForm() {
var password = document.forms["changePressword"]["oldpassword"].value;
if (password == null || password == "") {
alert("กรุณากรอก รหัสผ่านเก่า");
return false;
}
if(document.forms["changePressword"]["oldpassword"].value.length < 8)
{
alert('กรุณาระบุรหัสผ่านเก่าอย่างน้อย 8 ตัวอักษร');
return false;
}
var password = document.forms["changePressword"]["password"].value;
if (password == null || password == "") {
alert("กรุณากรอก รหัสผ่านใหม่");
......
......@@ -11,7 +11,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('ชื่อ');?><em>* </em></label>
<input type="text" name="firstname" id="firstname" value="" placeholder="FIRSTNAME" class="form-control-reg border-bottom-from">
<input type="text" name="firstname" id="firstname" value="" onkeypress="check_notnum();" placeholder="FIRSTNAME" class="form-control-reg border-bottom-from">
</div>
</div>
......@@ -20,7 +20,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('นามสกุล');?><em>* </em></label>
<input type="text" name="lastname" id="lastname" value="" placeholder="LASTNAME" class="form-control-reg border-bottom-from">
<input type="text" name="lastname" id="lastname" value="" onkeypress="check_notnum();" placeholder="LASTNAME" class="form-control-reg border-bottom-from">
</div>
</div>
......@@ -29,7 +29,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('ชื่อผู้ใช้งาน');?><em>* </em></label>
<input type="text" name="username" id="username" value="" placeholder="USERNAME" class="form-control-reg border-bottom-from">
<input type="text" name="username" id="username" value="" onkeypress="check_notnum();" placeholder="USERNAME" class="form-control-reg border-bottom-from">
</div>
</div>
......@@ -190,6 +190,21 @@
});
});
});
function check_phone() {
e_k=event.keyCode
//if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) {
if (e_k = 10 && (e_k < 48) || (e_k > 57)) {
event.returnValue = false;
alert("ขออภัยหมายเลขโทรศัพท์ ต้องเป็นตัวเลขเท่านั้น");
}
}
function check_notnum() {
e_k=event.keyCode
if ((e_k== 13 || e_k== 110) && (e_k > 48) || (e_k< 57)) {
event.returnValue = false;
alert("ข้อมูลผิดพลาด กรุณาใส่ข้อมูลที่เป็นตัวอักษรภาษาไทย [ก-ฮ] หรือภาษาอังกฤษให้ถูกต้อง");
}
}
function validateForm() {
var firstname = document.getElementById("firstname").value;
......@@ -489,14 +504,14 @@
<script>
function check_phone() {
e_k=event.keyCode
//if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) {
if (e_k = 10 && (e_k < 48) || (e_k > 57)) {
event.returnValue = false;
alert("ขออภัยหมายเลขโทรศัพท์ ต้องเป็นตัวเลขเท่านั้น");
}
}
// function check_phone() {
// e_k=event.keyCode
// //if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) {
// if (e_k = 10 && (e_k < 48) || (e_k > 57)) {
// event.returnValue = false;
// alert("ขออภัยหมายเลขโทรศัพท์ ต้องเป็นตัวเลขเท่านั้น");
// }
// }
/*var check = function() {
if (document.getElementById('password').value ==
document.getElementById('confirm_password').value) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment