where([$this->_table->aliasField('active') => 1]); return $query; } /** * Custom finder to log in users * * @param \Cake\ORM\Query $query Query object to modify * @param array $options Query options * @return \Cake\ORM\Query * @throws \BadMethodCallException */ public function findAuth(Query $query, array $options = []) { $identifier = $options['username'] ?? null; if (empty($identifier)) { throw new \BadMethodCallException(__d('cake_d_c/users', 'Missing \'username\' in options data')); } $where = $query->clause('where') ?: []; $query ->where(function ($exp) use ($identifier, $where) { $or = $exp->or_([$this->_table->aliasField('email') => $identifier]); return $or->add($where); }, [], true) ->find('active', $options); return $query; } }