diff --git a/Authenticatable.php b/Authenticatable.php index 46101d2aa..ae55d8fec 100644 --- a/Authenticatable.php +++ b/Authenticatable.php @@ -4,6 +4,16 @@ trait Authenticatable { + /** + * Get the name of the unique identifier for the user. + * + * @return string + */ + public function getAuthIdentifierName() + { + return $this->getKeyName(); + } + /** * Get the unique identifier for the user. * diff --git a/EloquentUserProvider.php b/EloquentUserProvider.php index e2b6dc7df..0df8c50c8 100755 --- a/EloquentUserProvider.php +++ b/EloquentUserProvider.php @@ -59,7 +59,7 @@ public function retrieveByToken($identifier, $token) $model = $this->createModel(); return $model->newQuery() - ->where($model->getKeyName(), $identifier) + ->where($model->getAuthIdentifierName(), $identifier) ->where($model->getRememberTokenName(), $token) ->first(); } diff --git a/GenericUser.php b/GenericUser.php index d349d4983..b6880c0ca 100755 --- a/GenericUser.php +++ b/GenericUser.php @@ -24,6 +24,16 @@ public function __construct(array $attributes) $this->attributes = $attributes; } + /** + * Get the name of the unique identifier for the user. + * + * @return string + */ + public function getAuthIdentifierName() + { + return 'id'; + } + /** * Get the unique identifier for the user. * @@ -31,7 +41,9 @@ public function __construct(array $attributes) */ public function getAuthIdentifier() { - return $this->attributes['id']; + $name = $this->getAuthIdentifierName(); + + return $this->attributes[$name]; } /**