public function checkForUserName(string $value, array $context): bool
    {
        // return true if config is not set
        if (empty($this->getConfig('noUserName'))) {
            return true;
        }
        // Get Config
        $firstNameField = $this->getConfig('userNameFields.firstname');
        $lastNameField = $this->getConfig('userNameFields.lastname');

        // No Usernames in Context
        if (empty($context['data'][$firstNameField]) || empty($context['data'][$lastNameField])) {
            if (!empty($context['data']['id'])) {
                $user = $this->_table->get($context['data']['id']);
                $firstname = $user->$firstNameField;
                $lastname = $user->$lastNameField;
            } else {
                // no name to check
                return true;
            }
        } else {
            $firstname = $context['data'][$firstNameField];
            $lastname = $context['data'][$lastNameField];
        }

        // validate password
        if (!empty($firstname) && strpos(strtolower($value), strtolower($firstname)) !== false) {
            return false;
        }
        if (!empty($lastname) && strpos(strtolower($value), strtolower($lastname)) !== false) {
            return false;
        }

        return true;
    }
public function checkForUserName(string $value, array $context): bool
    {
        // return true if config is not set
        if (empty($this->getConfig('noUserName'))) {
            return true;
        }
        // Get Config
        $firstNameField = $this->getConfig('userNameFields.firstname');
        $lastNameField = $this->getConfig('userNameFields.lastname');

        // No Usernames in Context
        if (empty($context['data'][$firstNameField]) || empty($context['data'][$lastNameField])) {
            if (!empty($context['data']['id'])) {
                $user = $this->_table->get($context['data']['id']);
                $firstname = $user->$firstNameField;
                $lastname = $user->$lastNameField;
            } else {
                // no name to check
                return true;
            }
        } else {
            $firstname = $context['data'][$firstNameField];
            $lastname = $context['data'][$lastNameField];
        }

        // validate password
        if (!empty($firstname) && strpos(strtolower($value), strtolower($firstname)) !== false) {
            return false;
        }
        if (!empty($lastname) && strpos(strtolower($value), strtolower($lastname)) !== false) {
            return false;
        }

        return true;
    }
public function checkForUserName ( string $ value , array $ context ) : bool { // return true if config is not set if ( empty ( $ this -> getConfig ( 'noUserName' ) ) ) { return true ; } // Get Config $ firstNameField = $ this -> getConfig ( 'userNameFields.firstname' ) ; $ lastNameField = $ this -> getConfig ( 'userNameFields.lastname' ) ; // No Usernames in Context if ( empty ( $ context [ 'data' ] [ $ firstNameField ] ) || empty ( $ context [ 'data' ] [ $ lastNameField ] ) ) { if ( ! empty ( $ context [ 'data' ] [ 'id' ] ) ) { $ user = $ this -> _table -> get ( $ context [ 'data' ] [ 'id' ] ) ; $ firstname = $ user -> $ firstNameField ; $ lastname = $ user -> $ lastNameField ; } else { // no name to check return true ; } } else { $ firstname = $ context [ 'data' ] [ $ firstNameField ] ; $ lastname = $ context [ 'data' ] [ $ lastNameField ] ; } // validate password if ( ! empty ( $ firstname ) && strpos ( strtolower ( $ value ) , strtolower ( $ firstname ) ) !== false ) { return false ; } if ( ! empty ( $ lastname ) && strpos ( strtolower ( $ value ) , strtolower ( $ lastname ) ) !== false ) { return false ; } return true ; }
Check for username used in password

@param  string $value   password
@param  array $context context data
@return bool
Check for username used in password