mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Merge pull request #9072 from biesbjerg/ticket-9070
Store user data in memory on login for stateless auth adapters
This commit is contained in:
commit
0a0ded16ad
2 changed files with 27 additions and 2 deletions
|
@ -611,8 +611,12 @@ class AuthComponent extends Component {
|
|||
$user = $this->identify($this->request, $this->response);
|
||||
}
|
||||
if ($user) {
|
||||
$this->Session->renew();
|
||||
$this->Session->write(static::$sessionKey, $user);
|
||||
if (static::$sessionKey) {
|
||||
$this->Session->renew();
|
||||
$this->Session->write(static::$sessionKey, $user);
|
||||
} else {
|
||||
static::$_user = $user;
|
||||
}
|
||||
$event = new CakeEvent('Auth.afterIdentify', $this, array('user' => $user));
|
||||
$this->_Collection->getController()->getEventManager()->dispatch($event);
|
||||
}
|
||||
|
|
|
@ -1721,6 +1721,27 @@ class AuthComponentTest extends CakeTestCase {
|
|||
$this->Auth->startup($this->Controller);
|
||||
}
|
||||
|
||||
/**
|
||||
* testStatelessLoginSetUserNoSessionStart method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testStatelessLoginSetUserNoSessionStart() {
|
||||
$user = array(
|
||||
'id' => 1,
|
||||
'username' => 'mark'
|
||||
);
|
||||
|
||||
AuthComponent::$sessionKey = false;
|
||||
$result = $this->Auth->login($user);
|
||||
$this->assertTrue($result);
|
||||
|
||||
$this->assertTrue($this->Auth->loggedIn());
|
||||
$this->assertEquals($user, $this->Auth->user());
|
||||
|
||||
$this->assertFalse($this->Auth->Session->started());
|
||||
}
|
||||
|
||||
/**
|
||||
* testStatelessAuthNoSessionStart method
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue