laravel/laravel — pull request #858 by franzliedke (2012-06-24 23:38:01+00:00)
Title: [Auth] Eloquent driver does now allow login via object

When passing an object to the `login()` method, the Eloquent driver doesn't allow me to login, even though this is supposed to work, trusting the documentation here.

So, code like this wont work:

Auth::login(MyUser::find(2));

While this, of course, works:

Auth::login(2);

The problem is this code in the Eloquent driver:

public function retrieve($id)
{
if (filter_var($id, FILTER_VALIDATE_INT) !== false)
{
return $this->model()->find($id);
}
}

This obviously doesn't allow for objects, which - in my humble opinion - should be allowed, as it has some benefits, when it comes to validating a user by object first.

----

Well, here's the pull request. I wrote this up as a bug report first but then thought "Meh, just fix it". Here we go.