Refactor Auth class to use Auth config closures.

This commit is contained in:
Taylor Otwell 2011-07-11 12:42:19 -07:00
parent 9ec8f4a5b6
commit 0d2cfd2417
1 changed files with 2 additions and 14 deletions

View File

@ -42,7 +42,7 @@ public static function user()
if (is_null(static::$user) and Session::has(static::$key))
{
static::$user = forward_static_call(array(static::model(), 'find'), Session::get(static::$key));
static::$user = call_user_func(Config::get('auth.by_id'), Session::get(static::$key));
}
return static::$user;
@ -59,9 +59,7 @@ public static function user()
*/
public static function login($username, $password)
{
$user = forward_static_call(array(static::model(), 'where'), Config::get('auth.username'), '=', $username)->first();
if ( ! is_null($user))
if ( ! is_null($user = call_user_func(Config::get('auth.by_username'), $username)))
{
if (Hash::check($password, $user->password))
{
@ -88,14 +86,4 @@ public static function logout()
static::$user = null;
}
/**
* Get the authentication model.
*
* @return string
*/
private static function model()
{
return '\\'.Config::get('auth.model');
}
}