public function updatePassword(string $currentPassword, string $newPassword, string $verifyPassword) : bool
    {
        // Get the current password
        $currentPassword = trim($currentPassword);

        // First off check that the current password matches the current password
        if (password_verify($currentPassword, $this->password)) {
            // Get the new password and the verify
            $newPassword = trim($newPassword);
            $verifyPassword = trim($verifyPassword);

            $data = [
                'new_password' => $newPassword,
                'verify_password' => $verifyPassword,
            ];

            //Ok let validate user password
            $validation = new Validation();
            $validation->add('new_password', new PresenceOf(['message' => 'The password is required.']));

            $validation->add(
                'new_password',
                new StringLength([
                    'min' => 8,
                    'messageMinimum' => 'Password is too short. Minimum 8 characters.',
                ])
            );

            $validation->add('new_password', new Confirmation([
                'message' => 'New password and confirmation do not match.',
                'with' => 'verify_password',
            ]));

            //validate this form for password
            $messages = $validation->validate($data);
            if (count($messages)) {
                foreach ($messages as $message) {
                    throw new Exception($message);
                }
            }

            // Check that they are the same
            if ($newPassword === $verifyPassword) {
                // Has the password and set it
                $this->password = self::passwordHash($newPassword);

                return true;
            } else {
                throw new Exception(_('New password and confirmation don\'t match . '));
            }
        }

        throw new Exception(_(' Your current password is incorrect .'));
    }
public function updatePassword(string $currentPassword, string $newPassword, string $verifyPassword) : bool
    {
        // Get the current password
        $currentPassword = trim($currentPassword);

        // First off check that the current password matches the current password
        if (password_verify($currentPassword, $this->password)) {
            // Get the new password and the verify
            $newPassword = trim($newPassword);
            $verifyPassword = trim($verifyPassword);

            $data = [
                'new_password' => $newPassword,
                'verify_password' => $verifyPassword,
            ];

            //Ok let validate user password
            $validation = new Validation();
            $validation->add('new_password', new PresenceOf(['message' => 'The password is required.']));

            $validation->add(
                'new_password',
                new StringLength([
                    'min' => 8,
                    'messageMinimum' => 'Password is too short. Minimum 8 characters.',
                ])
            );

            $validation->add('new_password', new Confirmation([
                'message' => 'New password and confirmation do not match.',
                'with' => 'verify_password',
            ]));

            //validate this form for password
            $messages = $validation->validate($data);
            if (count($messages)) {
                foreach ($messages as $message) {
                    throw new Exception($message);
                }
            }

            // Check that they are the same
            if ($newPassword === $verifyPassword) {
                // Has the password and set it
                $this->password = self::passwordHash($newPassword);

                return true;
            } else {
                throw new Exception(_('New password and confirmation don\'t match . '));
            }
        }

        throw new Exception(_(' Your current password is incorrect .'));
    }
public function updatePassword ( string $ currentPassword , string $ newPassword , string $ verifyPassword ) : bool { // Get the current password $ currentPassword = trim ( $ currentPassword ) ; // First off check that the current password matches the current password if ( password_verify ( $ currentPassword , $ this -> password ) ) { // Get the new password and the verify $ newPassword = trim ( $ newPassword ) ; $ verifyPassword = trim ( $ verifyPassword ) ; $ data = [ 'new_password' => $ newPassword , 'verify_password' => $ verifyPassword , ] ; //Ok let validate user password $ validation = new Validation ( ) ; $ validation -> add ( 'new_password' , new PresenceOf ( [ 'message' => 'The password is required.' ] ) ) ; $ validation -> add ( 'new_password' , new StringLength ( [ 'min' => 8 , 'messageMinimum' => 'Password is too short. Minimum 8 characters.' , ] ) ) ; $ validation -> add ( 'new_password' , new Confirmation ( [ 'message' => 'New password and confirmation do not match.' , 'with' => 'verify_password' , ] ) ) ; //validate this form for password $ messages = $ validation -> validate ( $ data ) ; if ( count ( $ messages ) ) { foreach ( $ messages as $ message ) { throw new Exception ( $ message ) ; } } // Check that they are the same if ( $ newPassword === $ verifyPassword ) { // Has the password and set it $ this -> password = self :: passwordHash ( $ newPassword ) ; return true ; } else { throw new Exception ( _ ( 'New password and confirmation don\'t match . ' ) ) ; } } throw new Exception ( _ ( ' Your current password is incorrect .' ) ) ; }
Update the password for a current user

@param string $newPassword
@return boolean
Update the password for a current user