user/controllers/UsersController.php
public function changePasswordAction()
    {
        $form = new ChangePasswordForm();

        if ($this->request->isPost()) {

            if (!$form->isValid($this->request->getPost())) {

                foreach ($form->getMessages() as $message) {
                    $this->flash->error($message);
                }
            } else {

                $user = $this->auth->getUser();

                $user->password = $this->security->hash($this->request->getPost('password'));
                $user->mustChangePassword = 'N';

                $passwordChange = new PasswordChanges();
                $passwordChange->user = $user;
                $passwordChange->ipAddress = $this->request->getClientAddress();
                $passwordChange->userAgent = $this->request->getUserAgent();

                if (!$passwordChange->save()) {
                    $this->flash->error($passwordChange->getMessages());
                } else {

                    $this->flash->success('Your password was successfully changed');

                    Tag::resetInput();
                }
            }
        }

        $this->view->form = $form;
    }
public function changePasswordAction()
    {
        $form = new ChangePasswordForm();

        if ($this->request->isPost()) {

            if (!$form->isValid($this->request->getPost())) {

                foreach ($form->getMessages() as $message) {
                    $this->flash->error($message);
                }
            } else {

                $user = $this->auth->getUser();

                $user->password = $this->security->hash($this->request->getPost('password'));
                $user->mustChangePassword = 'N';

                $passwordChange = new PasswordChanges();
                $passwordChange->user = $user;
                $passwordChange->ipAddress = $this->request->getClientAddress();
                $passwordChange->userAgent = $this->request->getUserAgent();

                if (!$passwordChange->save()) {
                    $this->flash->error($passwordChange->getMessages());
                } else {

                    $this->flash->success('Your password was successfully changed');

                    Tag::resetInput();
                }
            }
        }

        $this->view->form = $form;
    }
public function changePasswordAction ( ) { $ form = new ChangePasswordForm ( ) ; if ( $ this -> request -> isPost ( ) ) { if ( ! $ form -> isValid ( $ this -> request -> getPost ( ) ) ) { foreach ( $ form -> getMessages ( ) as $ message ) { $ this -> flash -> error ( $ message ) ; } } else { $ user = $ this -> auth -> getUser ( ) ; $ user -> password = $ this -> security -> hash ( $ this -> request -> getPost ( 'password' ) ) ; $ user -> mustChangePassword = 'N' ; $ passwordChange = new PasswordChanges ( ) ; $ passwordChange -> user = $ user ; $ passwordChange -> ipAddress = $ this -> request -> getClientAddress ( ) ; $ passwordChange -> userAgent = $ this -> request -> getUserAgent ( ) ; if ( ! $ passwordChange -> save ( ) ) { $ this -> flash -> error ( $ passwordChange -> getMessages ( ) ) ; } else { $ this -> flash -> success ( 'Your password was successfully changed' ) ; Tag :: resetInput ( ) ; } } } $ this -> view -> form = $ form ; }
Users must use this action to change its password
Users must use this action to change its password