Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jirisvoboda committed Jun 4, 2015
1 parent a666556 commit 5611cf4
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/components/AuthMeToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AuthMeToken {
/**
* Hash template
*/
const HASH_TEMPLATE = '%s-%s-%s';
const TOKEN_TEMPLATE = '%s-%s-%s';

/**
* @var int expiry time
Expand Down Expand Up @@ -71,7 +71,7 @@ public function getSecondaryKey()
*/
public function asString($secret)
{
$source = sprintf(self::HASH_TEMPLATE, $this->_primaryKey, $this->_secondaryKey, $this->_timestamp);
$source = sprintf(self::TOKEN_TEMPLATE, $this->_primaryKey, $this->_secondaryKey, $this->_timestamp);

return $this->_encrypt($source, $secret);
}
Expand Down Expand Up @@ -116,11 +116,9 @@ public static function initFromString($string, $secret)
{
$decrypted = self::_decrypt($string, $secret);

$parts = explode('-', $decrypted);

if (count($parts) == 3)
if (preg_match('/^(\d+)\-(.*)\-(\d+)$/', $decrypted, $matches))
{
return new self($parts[0], $parts[1], $parts[2]);
return new self($matches[1], $matches[2], $matches[3]);
}

return null;
Expand Down

0 comments on commit 5611cf4

Please sign in to comment.