Elgg  Version 1.9
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Elgg_PersistentLoginService Class Reference

Public Member Functions

 __construct (Elgg_Database $db, ElggSession $session, ElggCrypto $crypto, array $cookie_config, $cookie_token, $time=null)
 Constructor. More...
 
 makeLoginPersistent (ElggUser $user)
 Make the user's login persistent. More...
 
 removePersistentLogin ()
 Remove the persisted login token from client and server. More...
 
 handlePasswordChange (ElggUser $subject, ElggUser $modifier=null)
 Handle a password change. More...
 
 bootSession ()
 Boot the persistent login session, possibly returning the user who should be silently logged in. More...
 
 replaceLegacyToken (ElggUser $logged_in_user)
 Replace the user's token if it's a legacy hexadecimal token. More...
 
 getUserFromHash ($hash)
 Find a user with the given hash. More...
 

Public Attributes

 $_callable_get_user = 'get_user'
 DO NOT USE. More...
 
 $_callable_elgg_set_cookie = 'elgg_set_cookie'
 DO NOT USE. More...
 
 $_callable_sleep = 'sleep'
 DO NOT USE. More...
 

Protected Member Functions

 storeHash (ElggUser $user, $hash)
 Store a hash in the DB. More...
 
 removeHash ($hash)
 Remove a hash from the DB. More...
 
 handleDbException (DatabaseException $exception, $default=null)
 Swallow a schema not upgraded exception, otherwise rethrow it. More...
 
 removeAllHashes (ElggUser $user)
 Remove all the hashes associated with a user. More...
 
 hashToken ($token)
 Create a hash from the token. More...
 
 setCookie ($token)
 Store the token in the client cookie (or remove the cookie) More...
 
 setSession ($token)
 Store the token in the session (or remove it from the session) More...
 
 generateToken ()
 Generate a random token (base 64 URL) More...
 
 isLegacyToken ($token)
 Is the given token a legacy MD5 hash? More...
 

Protected Attributes

 $db
 
 $table
 
 $cookie_config
 
 $cookie_token
 
 $session
 
 $crypto
 
 $time
 

Detailed Description

Definition at line 25 of file PersistentLoginService.php.

Constructor & Destructor Documentation

Elgg_PersistentLoginService::__construct ( Elgg_Database  $db,
ElggSession  $session,
ElggCrypto  $crypto,
array  $cookie_config,
  $cookie_token,
  $time = null 
)

Constructor.

Parameters
Elgg_Database$dbThe DB service
ElggSession$sessionThe Elgg session
ElggCrypto$cryptoThe cryptography service
array$cookie_configThe persistent login cookie settings
string$cookie_tokenThe token from the request cookie
int$timeThe current time

Definition at line 37 of file PersistentLoginService.php.

Member Function Documentation

Elgg_PersistentLoginService::bootSession ( )

Boot the persistent login session, possibly returning the user who should be silently logged in.

Returns
ElggUser|null

Definition at line 106 of file PersistentLoginService.php.

Elgg_PersistentLoginService::generateToken ( )
protected

Generate a random token (base 64 URL)

The first char is always "z" to indicate the value has more entropy than the previously generated ones.

Returns
string

Definition at line 294 of file PersistentLoginService.php.

Elgg_PersistentLoginService::getUserFromHash (   $hash)

Find a user with the given hash.

Parameters
string$hashThe hashed token
Returns
ElggUser|null

Definition at line 150 of file PersistentLoginService.php.

Elgg_PersistentLoginService::handleDbException ( DatabaseException  $exception,
  $default = null 
)
protected

Swallow a schema not upgraded exception, otherwise rethrow it.

Parameters
DatabaseException$exceptionThe exception to handle
string$defaultThe value to return if the table doesn't exist yet
Returns
mixed
Exceptions
DatabaseException

Definition at line 218 of file PersistentLoginService.php.

Elgg_PersistentLoginService::handlePasswordChange ( ElggUser  $subject,
ElggUser  $modifier = null 
)

Handle a password change.

Parameters
ElggUser$subjectThe user whose password changed
ElggUser$modifierThe user who changed the password
Returns
void

Definition at line 91 of file PersistentLoginService.php.

Elgg_PersistentLoginService::hashToken (   $token)
protected

Create a hash from the token.

Parameters
string$tokenThe token to hash
Returns
string

Definition at line 248 of file PersistentLoginService.php.

Elgg_PersistentLoginService::isLegacyToken (   $token)
protected

Is the given token a legacy MD5 hash?

Parameters
string$tokenThe token to analyze
Returns
bool

Definition at line 304 of file PersistentLoginService.php.

Elgg_PersistentLoginService::makeLoginPersistent ( ElggUser  $user)

Make the user's login persistent.

Parameters
ElggUser$userThe user who logged in
Returns
void

Definition at line 61 of file PersistentLoginService.php.

Elgg_PersistentLoginService::removeAllHashes ( ElggUser  $user)
protected

Remove all the hashes associated with a user.

Parameters
ElggUser$userThe user for whom we're removing hashes
Returns
void

Definition at line 233 of file PersistentLoginService.php.

Elgg_PersistentLoginService::removeHash (   $hash)
protected

Remove a hash from the DB.

Parameters
string$hashThe hashed token to remove (unused before 1.9)
Returns
void

Definition at line 198 of file PersistentLoginService.php.

Elgg_PersistentLoginService::removePersistentLogin ( )

Remove the persisted login token from client and server.

Returns
void

Definition at line 74 of file PersistentLoginService.php.

Elgg_PersistentLoginService::replaceLegacyToken ( ElggUser  $logged_in_user)

Replace the user's token if it's a legacy hexadecimal token.

Parameters
ElggUser$logged_in_userThe logged in user
Returns
void

Definition at line 134 of file PersistentLoginService.php.

Elgg_PersistentLoginService::setCookie (   $token)
protected

Store the token in the client cookie (or remove the cookie)

Parameters
string$tokenEmpty string to remove cookie
Returns
void

Definition at line 260 of file PersistentLoginService.php.

Elgg_PersistentLoginService::setSession (   $token)
protected

Store the token in the session (or remove it from the session)

Parameters
string$tokenThe token to store in session. Empty string to remove.
Returns
void

Definition at line 278 of file PersistentLoginService.php.

Elgg_PersistentLoginService::storeHash ( ElggUser  $user,
  $hash 
)
protected

Store a hash in the DB.

Parameters
ElggUser$userThe user for whom we're storing the hash
string$hashThe hashed token
Returns
void

Definition at line 177 of file PersistentLoginService.php.

Member Data Documentation

Elgg_PersistentLoginService::$_callable_elgg_set_cookie = 'elgg_set_cookie'

DO NOT USE.

For unit test mocking private

Definition at line 353 of file PersistentLoginService.php.

Elgg_PersistentLoginService::$_callable_get_user = 'get_user'

DO NOT USE.

For unit test mocking private

Definition at line 347 of file PersistentLoginService.php.

Elgg_PersistentLoginService::$_callable_sleep = 'sleep'

DO NOT USE.

For unit test mocking private

Definition at line 359 of file PersistentLoginService.php.

Elgg_PersistentLoginService::$cookie_config
protected

Definition at line 321 of file PersistentLoginService.php.

Elgg_PersistentLoginService::$cookie_token
protected

Definition at line 326 of file PersistentLoginService.php.

Elgg_PersistentLoginService::$crypto
protected

Definition at line 336 of file PersistentLoginService.php.

Elgg_PersistentLoginService::$db
protected

Definition at line 311 of file PersistentLoginService.php.

Elgg_PersistentLoginService::$session
protected

Definition at line 331 of file PersistentLoginService.php.

Elgg_PersistentLoginService::$table
protected

Definition at line 316 of file PersistentLoginService.php.

Elgg_PersistentLoginService::$time
protected

Definition at line 341 of file PersistentLoginService.php.


The documentation for this class was generated from the following file: