Skip to content

Fixes for L5 native auth functionality. Updated contract in DoctrineUser... #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DoctrineUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
use Illuminate\Auth\UserProviderInterface;
use Illuminate\Contracts\Auth\UserProvider as UserProviderInterface;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Contracts\Hashing\Hasher;

Expand Down
4 changes: 2 additions & 2 deletions src/Traits/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function setPassword($password) {
* @return mixed
*/
public function getAuthIdentifier() {
return method_exists($this, 'getKeyName') ? $this->getKeyName() : 'id';
return method_exists($this, 'getKey') ? $this->getKey() : $this->id;
}

/**
Expand Down Expand Up @@ -60,6 +60,6 @@ public function setRememberToken($value) {
* @return string
*/
public function getRememberTokenName() {
return 'remember_token';
return 'rememberToken';
}
}
8 changes: 6 additions & 2 deletions src/Validation/DoctrinePresenceVerifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(EntityManagerInterface $entityManager)
*/
public function getCount($collection, $column, $value, $excludeId = null, $idColumn = null, array $extra = array())
{
$queryParts = ['SELECT COUNT(*) FROM', $collection, 'WHERE', "$column = ?"];
$queryParts = ['SELECT COUNT(*) as usercount FROM', $collection, 'WHERE', "$column = ?"];

if (!is_null($excludeId) && $excludeId != 'NULL') {
$queryParts[] = 'AND '.($idColumn ?: 'id').' <> ?';
Expand Down Expand Up @@ -62,7 +62,7 @@ public function getCount($collection, $column, $value, $excludeId = null, $idCol
*/
public function getMultiCount($collection, $column, array $values, array $extra = array())
{
$queryParts = ['SELECT COUNT(*) FROM', $collection, 'WHERE', "$column IN (?)"];
$queryParts = ['SELECT COUNT(*) as usercount FROM', $collection, 'WHERE', "$column IN (?)"];

foreach ($extra as $key => $extraValue) {
$queryParts[] = "AND $key = ?";
Expand All @@ -88,6 +88,10 @@ private function createQueryFrom(array $queryParts = [])
{
$rsm = new ResultSetMapping();

//If we don't set up a scalar result mapping, we'll always get back null from the hydrateColumnInfo function in
//the abstract class Doctrine\ORM\Internal\Hydration\AbstractHydrator, which all the hydrators extend.
$rsm = $rsm->addScalarResult('usercount','usercount','integer');

return $this->entityManager->createNativeQuery(implode(' ', $queryParts), $rsm);
}
}