From 9572329c499a2181339769d1d58ec33cc6a35e1c Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Mon, 25 Jun 2012 02:36:20 +0300 Subject: [PATCH 1/2] Allow Auth::login() to work with objects for the Eloquent driver. --- laravel/auth/drivers/eloquent.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/laravel/auth/drivers/eloquent.php b/laravel/auth/drivers/eloquent.php index 8c1c6a80..f90066be 100644 --- a/laravel/auth/drivers/eloquent.php +++ b/laravel/auth/drivers/eloquent.php @@ -7,15 +7,21 @@ class Eloquent extends Driver { * * If the user is a guest, null should be returned. * - * @param int $id + * @param int|object $token * @return mixed|null */ - public function retrieve($id) + public function retrieve($token) { + // We return an object here either if the passed token is an integer (ID) + // or if we are passed a model object of the correct type if (filter_var($id, FILTER_VALIDATE_INT) !== false) { return $this->model()->find($id); } + else if (get_class($id) == Config::get('auth.model')) + { + return $id; + } } /** From 0f5de55d5b4d2fb15049bf2ca208c2d3d7b56730 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Mon, 25 Jun 2012 14:53:15 +0300 Subject: [PATCH 2/2] Fix variable name in retrieve() method for Eloquent auth driver. --- laravel/auth/drivers/eloquent.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/laravel/auth/drivers/eloquent.php b/laravel/auth/drivers/eloquent.php index f90066be..e50a3142 100644 --- a/laravel/auth/drivers/eloquent.php +++ b/laravel/auth/drivers/eloquent.php @@ -14,13 +14,13 @@ class Eloquent extends Driver { { // We return an object here either if the passed token is an integer (ID) // or if we are passed a model object of the correct type - if (filter_var($id, FILTER_VALIDATE_INT) !== false) + if (filter_var($token, FILTER_VALIDATE_INT) !== false) { - return $this->model()->find($id); + return $this->model()->find($token); } - else if (get_class($id) == Config::get('auth.model')) + else if (get_class($token) == Config::get('auth.model')) { - return $id; + return $token; } }