Merge pull request #9072 from biesbjerg/ticket-9070

Store user data in memory on login for stateless auth adapters
This commit is contained in:
Mark Story 2016-07-07 22:40:05 -04:00 committed by GitHub
commit 0a0ded16ad
2 changed files with 27 additions and 2 deletions

View file

@ -611,8 +611,12 @@ class AuthComponent extends Component {
$user = $this->identify($this->request, $this->response);
}
if ($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);
}

View file

@ -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
*