Extend Auth::laravel to accept multiple params to verify
Signed-off-by: Jeffrey Way <jeffrey@envato.com>
This commit is contained in:
parent
ebcbbbb843
commit
9dd964c316
|
@ -26,12 +26,18 @@ public function retrieve($id)
|
||||||
*/
|
*/
|
||||||
public function attempt($arguments = array())
|
public function attempt($arguments = array())
|
||||||
{
|
{
|
||||||
|
$user = $this->model()->where(function($query) use($arguments) {
|
||||||
$username = Config::get('auth.username');
|
$username = Config::get('auth.username');
|
||||||
|
|
||||||
$user = $this->model()->where($username, '=', $arguments['username'])->first();
|
$query->where($username, '=', $arguments['username']);
|
||||||
|
|
||||||
// This driver uses a basic username and password authentication scheme
|
foreach( array_except($arguments, array('username', 'password')) as $column => $val )
|
||||||
// so if the credentials match what is in the database we will just
|
{
|
||||||
|
$query->where($column, '=', $val);
|
||||||
|
}
|
||||||
|
})->first();
|
||||||
|
|
||||||
|
// If the credentials match what is in the database we will just
|
||||||
// log the user into the application and remember them if asked.
|
// log the user into the application and remember them if asked.
|
||||||
$password = $arguments['password'];
|
$password = $arguments['password'];
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,9 @@ public function retrieve($id)
|
||||||
*/
|
*/
|
||||||
public function attempt($arguments = array())
|
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
|
// If the credentials match what is in the database we will just
|
||||||
// so if the credentials match what is in the database we will just
|
|
||||||
// log the user into the application and remember them if asked.
|
// log the user into the application and remember them if asked.
|
||||||
$password = $arguments['password'];
|
$password = $arguments['password'];
|
||||||
|
|
||||||
|
@ -48,18 +47,25 @@ public function attempt($arguments = array())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the user from the database table by username.
|
* Get the user from the database table.
|
||||||
*
|
*
|
||||||
* @param mixed $value
|
* @param mixed $array
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
protected function get_user($value)
|
protected function get_user($arguments)
|
||||||
{
|
{
|
||||||
$table = Config::get('auth.table');
|
$table = Config::get('auth.table');
|
||||||
|
|
||||||
|
return DB::table($table)->where(function($query) use($arguments) {
|
||||||
$username = Config::get('auth.username');
|
$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')) as $column => $val )
|
||||||
|
{
|
||||||
|
$query->where($column, '=', $val);
|
||||||
|
}
|
||||||
|
})->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue