Token
class Token (View source)
Constants
VALID_HASH_TIME_THRESHOLD |
Duration (in seconds) of a token. |
DEFAULT_TOKEN_NAME |
The default name of the token parameters. |
Methods
Get the error message to be shown to the users when a token is not valid.
Create the HTML code of a token.
Generates a token for a given action. This is a token in the form of time:hash, where hash is md5(time:userID:action:pepper).
Generate a token and return it as a query string variable (eg 'ccm_token=...').
Validate a token against a given action.
Details
string
getErrorMessage()
Get the error message to be shown to the users when a token is not valid.
string|void
output(string $action = '', bool $return = false)
Create the HTML code of a token.
string
generate(string $action = '', int $time = null)
Generates a token for a given action. This is a token in the form of time:hash, where hash is md5(time:userID:action:pepper).
string
getParameter(string $action = '')
Generate a token and return it as a query string variable (eg 'ccm_token=...').
bool
validate(string $action = '', string $token = null)
Validate a token against a given action.
Basically, we check the passed hash to see if: a. the hash is valid. That means it computes in the time:action:pepper format b. the time included next to the hash is within the threshold.