Beispiel #1
0
 public function requestChangePassword($user_model_record)
 {
     //reset token and send email
     $new_token = UtilLib::generateToken();
     $this->UserAccount->save(array('id' => $user_model_record['UserAccount'][0]['id'], 'reset_token_password' => $new_token, 'reset_token_time' => UtilLib::getCurrentDateTime()), array('validate' => FALSE));
     $sf_email = new SFEmail();
     $result = $sf_email->sendEmail('user_forgot_password', $user_model_record['UserModel']['email'], $user_model_record['UserModel']['name'], array('values' => array('[:account_name]' => $user_model_record['UserModel']['name'], '[:reset_url]' => Router::url('/user/account/resetPassword', TRUE) . '?token=' . $new_token)));
     return $result;
 }
Beispiel #2
0
 public function forgotPassword()
 {
     $this->layout = "login";
     if (!empty($this->request->data)) {
         $data = $this->UserModel->findByUserEmail($this->request->data['UserModel']['user_email']);
         if (empty($data)) {
             $this->Session->setFlash(__('The email you entered is not exist'), 'flash/error');
         } else {
             $data['UserModel']['user_activation_key'] = UtilLib::generateToken();
             $data['UserModel']['user_registered'] = date('Y-m-d H:i:s');
             $this->UserModel->save($data['UserModel']);
             App::uses('CakeEmail', 'Network/Email');
             $Email = new CakeEmail('noreply');
             $noreplyConf = $Email->config();
             $Email->emailFormat('html');
             $Email->template('User.reset_password');
             $Email->viewVars(array('token' => $data['UserModel']['user_activation_key'], 'name' => $data['UserModel']['display_name']));
             $Email->from($noreplyConf['from']);
             $Email->to($data['UserModel']['user_email']);
             $Email->subject(__('Please activate your account'));
             $Email->send();
             $this->Session->setFlash(__('Recover password link is sent'), 'flash/error');
         }
     }
 }