50 $prefix = $this->db->getTablePrefix();
51 $this->
table =
"{$prefix}users_remember_me_cookies";
52 $this->time = is_numeric(
$time) ? (int)
$time : time();
75 if ($this->cookie_token) {
76 $client_hash = $this->
hashToken($this->cookie_token);
93 if (!$modifier || ($modifier->guid !== $subject->guid) || !$this->cookie_token) {
107 if (!$this->cookie_token) {
112 $cookie_hash = $this->
hashToken($this->cookie_token);
122 call_user_func($this->_callable_sleep, 1);
135 if (!$this->cookie_token || !$this->
isLegacyToken($this->cookie_token)) {
155 $hash = $this->db->sanitizeString($hash);
156 $query =
"SELECT guid FROM {$this->table} WHERE code = '$hash'";
158 $user_row = $this->db->getDataRow($query);
166 $user = call_user_func($this->_callable_get_user, $user_row->guid);
179 $hash = $this->db->sanitizeString($hash);
182 INSERT INTO {$this->table} (code, guid, timestamp) 183 VALUES ('$hash', {$user->guid}, $time) 186 $this->db->insertData($query);
199 $hash = $this->db->sanitizeString($hash);
201 $query =
"DELETE FROM {$this->table} WHERE code = '$hash'";
203 $this->db->deleteData($query);
219 if (
false !== strpos($exception->getMessage(),
"users_remember_me_cookies' doesn't exist")) {
234 $query =
"DELETE FROM {$this->table} WHERE guid = '{$user->guid}'";
236 $this->db->deleteData($query);
261 $cookie =
new ElggCookie($this->cookie_config[
'name']);
262 foreach (array(
'expire',
'path',
'domain',
'secure',
'httponly') as
$key) {
263 $cookie->$key = $this->cookie_config[
$key];
267 $cookie->expire = $this->time - (86400 * 30);
269 call_user_func($this->_callable_elgg_set_cookie, $cookie);
280 $this->session->set(
'code',
$token);
282 $this->session->remove(
'code');
295 return 'z' . $this->crypto->getRandomString(31);
setCookie($token)
Store the token in the client cookie (or remove the cookie)
removePersistentLogin()
Remove the persisted login token from client and server.
__construct(Elgg_Database $db, ElggSession $session, ElggCrypto $crypto, array $cookie_config, $cookie_token, $time=null)
Constructor.
replaceLegacyToken(ElggUser $logged_in_user)
Replace the user's token if it's a legacy hexadecimal token.
makeLoginPersistent(ElggUser $user)
Make the user's login persistent.
handlePasswordChange(ElggUser $subject, ElggUser $modifier=null)
Handle a password change.
handleDbException(DatabaseException $exception, $default=null)
Swallow a schema not upgraded exception, otherwise rethrow it.
getUserFromHash($hash)
Find a user with the given hash.
$_callable_elgg_set_cookie
DO NOT USE.
isLegacyToken($token)
Is the given token a legacy MD5 hash?
setSession($token)
Store the token in the session (or remove it from the session)
storeHash(ElggUser $user, $hash)
Store a hash in the DB.
bootSession()
Boot the persistent login session, possibly returning the user who should be silently logged in...
hashToken($token)
Create a hash from the token.
generateToken()
Generate a random token (base 64 URL)
$_callable_sleep
DO NOT USE.
removeHash($hash)
Remove a hash from the DB.
$_callable_get_user
DO NOT USE.
removeAllHashes(ElggUser $user)
Remove all the hashes associated with a user.