added remember_me cookie config option.
This commit is contained in:
parent
ac277c58e6
commit
8066a595bc
|
@ -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',
|
||||||
|
|
||||||
);
|
);
|
|
@ -16,13 +16,6 @@ class Auth {
|
||||||
*/
|
*/
|
||||||
const user_key = 'laravel_user_id';
|
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.
|
* 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.
|
// exists, we'll attempt to recall the user based on the cookie value.
|
||||||
// Since all cookies contain a fingerprint hash verifying that they
|
// Since all cookies contain a fingerprint hash verifying that they
|
||||||
// haven't changed, we can trust it.
|
// 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))
|
if (is_null(static::$user) and ! is_null($recaller))
|
||||||
{
|
{
|
||||||
|
@ -196,7 +189,9 @@ protected static function remember($id)
|
||||||
|
|
||||||
extract($config, EXTR_SKIP);
|
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
|
// When forgetting the cookie, we need to also pass in the path and
|
||||||
// domain that would have been used when the cookie was originally
|
// domain that would have been used when the cookie was originally
|
||||||
// set by the framework, otherwise it will not be deleted.
|
// 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);
|
Session::forget(Auth::user_key);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue