From 8066a595bc83cec5c2b3449babdae158ba03ebbb Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 1 Feb 2012 08:52:57 -0600 Subject: [PATCH] added remember_me cookie config option. --- application/config/auth.php | 15 ++++++++++++++- laravel/auth.php | 17 +++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/application/config/auth.php b/application/config/auth.php index 36343d4f..d0137583 100644 --- a/application/config/auth.php +++ b/application/config/auth.php @@ -63,6 +63,19 @@ | */ - 'logout' => function($user) {} + 'logout' => function($user) {}, + + /* + |-------------------------------------------------------------------------- + | "Remember Me" Cookie Name + |-------------------------------------------------------------------------- + | + | Here you may specify the cookie name that will be used for the cookie + | that serves as the "remember me" token. Of course, a sensible default + | has been set for you, so you probably don't need to change it. + | + */ + + 'cookie' => 'laravel_remember', ); \ No newline at end of file diff --git a/laravel/auth.php b/laravel/auth.php index d1828c5b..0881e968 100644 --- a/laravel/auth.php +++ b/laravel/auth.php @@ -16,13 +16,6 @@ class Auth { */ const user_key = 'laravel_user_id'; - /** - * The key used when setting the "remember me" cookie. - * - * @var string - */ - const remember_key = 'laravel_remember'; - /** * Determine if the user of the application is not logged in. * @@ -76,7 +69,7 @@ public static function user() // exists, we'll attempt to recall the user based on the cookie value. // Since all cookies contain a fingerprint hash verifying that they // haven't changed, we can trust it. - $recaller = Cookie::get(Auth::remember_key); + $recaller = Cookie::get($config['cookie']); if (is_null(static::$user) and ! is_null($recaller)) { @@ -196,7 +189,9 @@ protected static function remember($id) extract($config, EXTR_SKIP); - Cookie::forever(Auth::remember_key, $recaller, $path, $domain, $secure); + $cookie = Config::get('auth.cookie'); + + Cookie::forever($cookie, $recaller, $path, $domain, $secure); } /** @@ -220,7 +215,9 @@ public static function logout() // When forgetting the cookie, we need to also pass in the path and // domain that would have been used when the cookie was originally // set by the framework, otherwise it will not be deleted. - Cookie::forget(Auth::remember_key, $path, $domain, $secure); + $cookie = Config::get('auth.cookie'); + + Cookie::forget($cookie, $path, $domain, $secure); Session::forget(Auth::user_key); }