where([$this->_table->aliasField('active') => 1]); return $query; } /** * Custom finder to log in users * * @param Query $query Query object to modify * @param array $options Query options * @return Query * @throws \BadMethodCallException */ public function findAuth(Query $query, array $options = []) { $identifier = Hash::get($options, 'username'); if (empty($identifier)) { throw new \BadMethodCallException(__d('CakeDC/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; } }