Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function change_pass()
- {
- $this->layout = 'base_layout';
- if ($this->request->is('post','put'))
- {
- $old_pass = $this->request->data['User']['old_password'];
- $new_pass = $this->request->data['User']['new_password'];
- $con_pass = $this->request->data['User']['confirm_password'];
- if($con_pass == $new_pass)
- {
- // pr($this->request->data);
- $params =
- array(
- 'conditions' => array(
- 'username' => $_SESSION['username'],
- 'password' => $old_pass//$this->request->data['User']['old_password']
- )
- );
- $result = $this->User->find('all', $params);
- if($result != null)
- {
- $this->User->id = $result[0]['User']['id'];
- $this->User->set(array('password'=>$new_pass));
- if($this->User->save())
- {
- $this->Flash->success(__('Success! Password successfully changed! '));
- }
- else {
- # code...
- $this->Flash->error(
- __('Oops! Something went wrong!')
- );
- }
- }
- else {
- $this->Flash->error(
- __('Oops! Sorry your current password is invalid!')
- );
- }
- }
- else {
- $this->Flash->error(
- __('Oops! Sorry your Passwords are not matched!')
- );
- }
- }
- }
Add Comment
Please, Sign In to add comment