From 11c67a56ccc0d51dd16d8fa5f73faabcf96deedc Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Mon, 28 May 2012 11:31:21 +0200 Subject: [PATCH] added eloquent model detection to eloquent auth driver --- laravel/auth/drivers/driver.php | 4 ---- laravel/auth/drivers/eloquent.php | 25 ++++++++++++++++++++++++- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/laravel/auth/drivers/driver.php b/laravel/auth/drivers/driver.php index 21a5f5ad..5785291a 100644 --- a/laravel/auth/drivers/driver.php +++ b/laravel/auth/drivers/driver.php @@ -107,10 +107,6 @@ abstract public function attempt($arguments = array()); */ public function login($token, $remember = false) { - // if the token is an Eloquent model - // set the token from the id field - if ($token instanceof Eloquent) $token = $token->get_key(); - $this->token = $token; $this->store($token); diff --git a/laravel/auth/drivers/eloquent.php b/laravel/auth/drivers/eloquent.php index 5c0437d6..410de34e 100644 --- a/laravel/auth/drivers/eloquent.php +++ b/laravel/auth/drivers/eloquent.php @@ -15,7 +15,30 @@ public function retrieve($id) if (filter_var($id, FILTER_VALIDATE_INT) !== false) { return $this->model()->find($id); - } + } + } + + /** + * Login the user assigned to the given token. + * + * The token is typically a numeric ID for the user. + * + * @param mixed $token + * @param bool $remember + * @return bool + */ + public function login($token, $remember = false) + { + // if the token is an Eloquent model get the primary key + if ($token instanceof \Eloquent) $token = $token->get_key(); + + $this->token = $token; + + $this->store($token); + + if ($remember) $this->remember($token); + + return true; } /**