Elgg\PersistentLoginService::replaceLegacyToken PHP Method

replaceLegacyToken() public method

Replace the user's token if it's a legacy hexadecimal token
public replaceLegacyToken ( ElggUser $logged_in_user ) : void
$logged_in_user ElggUser The logged in user
return void
    public function replaceLegacyToken(\ElggUser $logged_in_user)
    {
        if (!$this->cookie_token || !$this->isLegacyToken($this->cookie_token)) {
            return;
        }
        // replace user's old weaker-entropy code with new one
        $this->removeHash($this->hashToken($this->cookie_token));
        $this->makeLoginPersistent($logged_in_user);
    }

Usage Example

Beispiel #1
0
 function testLegacyCookiesAreReplacedInDbCookieAndSession()
 {
     $this->svc = $this->getSvcWithCookie(str_repeat('a', 32));
     $this->dbMock->expects($this->atLeastOnce())->method('deleteData');
     $this->dbMock->expects($this->once())->method('insertData');
     $this->svc->replaceLegacyToken($this->user123);
     $this->assertSame($this->mockToken, $this->lastCookieSet->value);
     $this->assertSame($this->mockToken, $this->session->get('code'));
 }