Commit c937f98b authored by Taylor Otwell's avatar Taylor Otwell

Merge pull request #932 from JeffreyWay/feature/auth_attempt_extend

Extend Auth::Attempt()
parents 19c64f1e c659a926
......@@ -25,13 +25,20 @@ class Eloquent extends Driver {
* @return void
*/
public function attempt($arguments = array())
{
$user = $this->model()->where(function($query) use($arguments)
{
$username = Config::get('auth.username');
$user = $this->model()->where($username, '=', $arguments['username'])->first();
$query->where($username, '=', $arguments['username']);
foreach(array_except($arguments, array('username', 'password', 'remember')) as $column => $val)
{
$query->where($column, '=', $val);
}
})->first();
// This driver uses a basic username and password authentication scheme
// so if the credentials match what is in the database we will just
// If the credentials match what is in the database we will just
// log the user into the application and remember them if asked.
$password = $arguments['password'];
......
......@@ -30,10 +30,9 @@ class Fluent extends Driver {
*/
public function attempt($arguments = array())
{
$user = $this->get_user($arguments['username']);
$user = $this->get_user($arguments);
// This driver uses a basic username and password authentication scheme
// so if the credentials match what is in the database we will just
// If the credentials match what is in the database we will just
// log the user into the application and remember them if asked.
$password = $arguments['password'];
......@@ -48,18 +47,26 @@ class Fluent extends Driver {
}
/**
* Get the user from the database table by username.
* Get the user from the database table.
*
* @param mixed $value
* @param array $arguments
* @return mixed
*/
protected function get_user($value)
protected function get_user($arguments)
{
$table = Config::get('auth.table');
return DB::table($table)->where(function($query) use($arguments)
{
$username = Config::get('auth.username');
return DB::table($table)->where($username, '=', $value)->first();
$query->where($username, '=', $arguments['username']);
foreach(array_except($arguments, array('username', 'password', 'remember')) as $column => $val)
{
$query->where($column, '=', $val);
}
})->first();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment