Skip to content

Commit 9aeeb26

Browse files
brataoandig
authored andcommitted
Keep sessions and clear Redis (#109)
1 parent e2ab103 commit 9aeeb26

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

Bootstraps/Laravel.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,15 @@ public function getApplication()
8484
$auth->extend('session', function($app, $name, $config) {
8585
$provider = $app['auth']->createUserProvider($config['provider']);
8686
$guard = new \PHPPM\Laravel\SessionGuard($name, $provider, $app['session.store'], null, $app);
87-
$guard->setCookieJar($app['cookie']);
88-
$guard->setDispatcher($app['events']);
89-
$guard->setRequest($app->refresh('request', $guard, 'setRequest'));
87+
if (method_exists($guard, 'setCookieJar')) {
88+
$guard->setCookieJar($this->app['cookie']);
89+
}
90+
if (method_exists($guard, 'setDispatcher')) {
91+
$guard->setDispatcher($this->app['events']);
92+
}
93+
if (method_exists($guard, 'setRequest')) {
94+
$guard->setRequest($this->app->refresh('request', $guard, 'setRequest'));
95+
}
9096

9197
return $guard;
9298
});
@@ -118,6 +124,7 @@ public function postHandle($app)
118124
//note that lumen does not have the getProvider method
119125
if (method_exists($this->app, 'getProvider')) {
120126
//reset debugbar if available
127+
$this->resetProvider('\Illuminate\Redis\RedisServiceProvider');
121128
$this->resetProvider('\Illuminate\Cookie\CookieServiceProvider');
122129
$this->resetProvider('\Illuminate\Session\SessionServiceProvider');
123130
}

Laravel/SessionGuard.php

+21
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,27 @@ public function setRequest(Request $request)
5656

5757
return parent::setRequest($request);
5858
}
59+
60+
/**
61+
* Get a unique identifier for the auth session value.
62+
*
63+
* @return string
64+
*/
65+
public function getName()
66+
{
67+
return 'login_'.$this->name.'_'.sha1(parent::class);
68+
}
5969

70+
/**
71+
* Get the name of the cookie used to store the "recaller".
72+
*
73+
* @return string
74+
*/
75+
public function getRecallerName()
76+
{
77+
return 'remember_'.$this->name.'_'.sha1(parent::class);
78+
}
79+
6080
/**
6181
* Reset the state of current class instance.
6282
*
@@ -69,5 +89,6 @@ protected function reset()
6989
$this->viaRemember = false;
7090
$this->loggedOut = false;
7191
$this->tokenRetrievalAttempted = false;
92+
$this->recallAttempted = false;
7293
}
7394
}

0 commit comments

Comments
 (0)