29 public $_callable_elgg_set_cookie =
'elgg_set_cookie';
43 protected \
Elgg\Security\Crypto $crypto,
47 $global_cookies_config = $config->getCookieConfig();
49 $this->cookie_config = $global_cookies_config[
'remember_me'];
50 $this->cookie_token = $request->cookies->get($this->cookie_config[
'name'],
'');
61 $token = $this->generateToken();
62 $hash = $this->hashToken(
$token);
64 $this->cookie_table->insertHash($user, $hash);
66 $this->setSessionToken(
$token);
75 if ($this->cookie_token) {
76 $client_hash = $this->hashToken($this->cookie_token);
77 $this->cookie_table->deleteHash($client_hash);
81 $this->setSessionToken(
'');
93 $this->cookie_table->deleteAllHashes($subject);
94 if (!$modifier || ($modifier->guid !== $subject->guid) || !$this->cookie_token) {
98 $this->makeLoginPersistent($subject);
108 if (!$this->cookie_token) {
113 $user = $this->getUserFromToken($this->cookie_token);
115 $this->setSessionToken($this->cookie_token);
120 $this->setCookie(
'');
136 $hash = $this->hashToken($token);
141 $user_row = $this->cookie_table->getRowFromHash($hash);
142 if (empty($user_row)) {
158 if (!$this->cookie_token) {
164 $this->cookie_table->updateHash($user, $this->hashToken($this->cookie_token));
167 $this->setCookie($this->cookie_token);
182 $expires = Values::normalizeTime($this->cookie_config[
'expire']);
186 if (
$time->getTimestamp() > time()) {
190 return (
bool) $this->cookie_table->deleteExpiredHashes(
$time->getTimestamp());
214 $cookie = new \ElggCookie($this->cookie_config[
'name']);
215 foreach ([
'expire',
'path',
'domain',
'secure',
'httpOnly'] as
$key) {
216 $cookie->$key = $this->cookie_config[strtolower($key)];
221 $cookie->expire = $this->
getCurrentTime(
'-30 days')->getTimestamp();
224 call_user_func($this->_callable_elgg_set_cookie, $cookie);
236 $this->session->set(
'code', $token);
238 $this->session->remove(
'code');
251 return 'z' . $this->crypto->getRandomString(31);
makeLoginPersistent(\ElggUser $user)
Make the user's login persistent.
bootSession()
Boot the persistent login session, possibly returning the user who should be silently logged in...
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
if(!$annotation instanceof ElggAnnotation) $time
trait TimeUsing
Adds methods for setting the current time (for testing)
setSessionToken(string $token)
Store the token in the session (or remove it from the session)
Manage the users_remember_me_cookies table.
$config
Advanced site settings, debugging section.
getCurrentTime($modifier= '')
Get the (cloned) time.
removeExpiredTokens($time)
Remove all persistent codes from the database which have expired based on the cookie config...
get_user(int $guid)
Elgg users Functions to manage multiple or single users in an Elgg install.
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
generateToken()
Generate a random token (base 64 URL)
if(isset($_COOKIE['elggperm'])) $session
updateTokenUsage(\ElggUser $user)
Update the timestamp linked to a persistent cookie code, this indicates that the code was used recent...
removePersistentLogin()
Remove the persisted login token from client and server.
setCookie(string $token)
Store the token in the client cookie (or remove the cookie)
hashToken(string $token)
Create a hash from the token.
handlePasswordChange(\ElggUser $subject,\ElggUser $modifier=null)
Handle a password change.
__construct(protected UsersRememberMeCookiesTable $cookie_table, protected\ElggSession $session, protected\Elgg\Security\Crypto $crypto,\Elgg\Config $config,\Elgg\Http\Request $request)
Constructor.
getUserFromToken(string $token)
Get a user from a persistent cookie token.