mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-12 06:56:24 +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);
|
$user = $this->identify($this->request, $this->response);
|
||||||
}
|
}
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$this->Session->renew();
|
if (static::$sessionKey) {
|
||||||
$this->Session->write(static::$sessionKey, $user);
|
$this->Session->renew();
|
||||||
|
$this->Session->write(static::$sessionKey, $user);
|
||||||
|
} else {
|
||||||
|
static::$_user = $user;
|
||||||
|
}
|
||||||
$event = new CakeEvent('Auth.afterIdentify', $this, array('user' => $user));
|
$event = new CakeEvent('Auth.afterIdentify', $this, array('user' => $user));
|
||||||
$this->_Collection->getController()->getEventManager()->dispatch($event);
|
$this->_Collection->getController()->getEventManager()->dispatch($event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1721,6 +1721,27 @@ class AuthComponentTest extends CakeTestCase {
|
||||||
$this->Auth->startup($this->Controller);
|
$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
|
* testStatelessAuthNoSessionStart method
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue