public function newPassword($id = null)
    {
        $user = $this->Users->get($id, [
            'contain' => []
        ]);

        $user->accessible('send_mail', true); // checkbox to send an e-mail

        if ($this->request->is(['patch', 'post', 'put'])) {
            $user = $this->Users->patchEntity($user, $this->request->data);
            if ($this->Users->save($user)) {
                if ($user->send_mail) {
                    $this->EmailListener->passwordConfirmation($user);
                }
                $this->Flash->success(__('The user has been saved.'));
                return $this->redirect($this->referer());
            } else {
                $this->Flash->error(__('The password could not be saved. Please, try again.'));
            }
        }

        $this->set(compact('user'));

        $this->render(Configure::read('CM.AdminUserViews.newPassword'));
    }
public function newPassword($id = null)
    {
        $user = $this->Users->get($id, [
            'contain' => []
        ]);

        $user->accessible('send_mail', true); // checkbox to send an e-mail

        if ($this->request->is(['patch', 'post', 'put'])) {
            $user = $this->Users->patchEntity($user, $this->request->data);
            if ($this->Users->save($user)) {
                if ($user->send_mail) {
                    $this->EmailListener->passwordConfirmation($user);
                }
                $this->Flash->success(__('The user has been saved.'));
                return $this->redirect($this->referer());
            } else {
                $this->Flash->error(__('The password could not be saved. Please, try again.'));
            }
        }

        $this->set(compact('user'));

        $this->render(Configure::read('CM.AdminUserViews.newPassword'));
    }
public function newPassword ( $ id = null ) { $ user = $ this -> Users -> get ( $ id , [ 'contain' => [ ] ] ) ; $ user -> accessible ( 'send_mail' , true ) ; // checkbox to send an e-mail if ( $ this -> request -> is ( [ 'patch' , 'post' , 'put' ] ) ) { $ user = $ this -> Users -> patchEntity ( $ user , $ this -> request -> data ) ; if ( $ this -> Users -> save ( $ user ) ) { if ( $ user -> send_mail ) { $ this -> EmailListener -> passwordConfirmation ( $ user ) ; } $ this -> Flash -> success ( __ ( 'The user has been saved.' ) ) ; return $ this -> redirect ( $ this -> referer ( ) ) ; } else { $ this -> Flash -> error ( __ ( 'The password could not be saved. Please, try again.' ) ) ; } } $ this -> set ( compact ( 'user' ) ) ; $ this -> render ( Configure :: read ( 'CM.AdminUserViews.newPassword' ) ) ; }
New Password method

Admin action to change someones password.

@param string|null $id User id.
@return void|\Cake\Network\Respose
New Password method