From 6e0d69e23a7e4ffba3fb868dcbb697d38399684f Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Sun, 9 Oct 2011 12:49:41 -0400 Subject: [PATCH] Refactered user and fixed parse error. --- laravel/security/auth.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/laravel/security/auth.php b/laravel/security/auth.php index 98a12dda..69122dab 100644 --- a/laravel/security/auth.php +++ b/laravel/security/auth.php @@ -52,23 +52,19 @@ class Auth { $id = IoC::container()->core('session')->get(Auth::user_key); - if (is_null($id) AND ! is_null($cookie = Crypter::decrypt(\Cookie::get('remember')))) + static::$user = call_user_func(Config::get('auth.user'), $id); + + if (is_null(static::$user) AND ! is_null($cookie = Crypter::decrypt(\Cookie::get('remember')))) { $cookie = explode('|', $cookie); - if ($cookie[2] == md5(\Request::server('HTTP_USER_AGENT'))) + if ($cookie[2] == md5(\Request::server('HTTP_USER_AGENT')) + AND ! is_null(static::$user = call_user_func(Config::get('auth.user'), $cookie[0]))) { - $id = $cookie[0]; - } - - // Attempt to find the user and set the login session. - if ( ! is_null($user = call_user_func(Config::get('auth.user'), $id))) - { - static::login($user); - return static::$user; + static::login(static::$user); } } - return static::$user = call_user_func(Config::get('auth.user'), $id); + return static::$user; } /** @@ -138,7 +134,7 @@ class Auth { public static function remember($user, $ttl = 10080) { static::$user = $user; - $cookie = Crypter::encrypt(implode('|', array($user->id, \Request::ip(), md5(\Request::server('HTTP_USER_AGENT')), time())); + $cookie = Crypter::encrypt(implode('|', array($user->id, \Request::ip(), md5(\Request::server('HTTP_USER_AGENT')), time()))); \Cookie::put('remember', $cookie, $ttl); } } \ No newline at end of file