Removed unneeded base64 encoding and added code to cope with wrong fromed JSON code
This commit is contained in:
parent
628514eb4e
commit
ed87808391
@ -38,7 +38,6 @@ class ClubsHelperAuth
|
|||||||
$value['sign'] = convert_uuencode($signature);
|
$value['sign'] = convert_uuencode($signature);
|
||||||
|
|
||||||
$jsonValue = json_encode($value);
|
$jsonValue = json_encode($value);
|
||||||
$uue = convert_uuencode($jsonValue);
|
|
||||||
|
|
||||||
$c = Factory::getApplication()->input->cookie;
|
$c = Factory::getApplication()->input->cookie;
|
||||||
if(! $keep)
|
if(! $keep)
|
||||||
@ -51,20 +50,23 @@ class ClubsHelperAuth
|
|||||||
$time = time() + 3600*24*15;
|
$time = time() + 3600*24*15;
|
||||||
$c->set('clubsLoginKeepLoggedIn', 'true', time() + 3600*24*356*10);
|
$c->set('clubsLoginKeepLoggedIn', 'true', time() + 3600*24*356*10);
|
||||||
}
|
}
|
||||||
$c->set('clubsLogin', $uue, $time);
|
$c->set('clubsLogin', $jsonValue, $time);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkCookie()
|
public function checkCookie()
|
||||||
{
|
{
|
||||||
$cookie = Factory::getApplication()->input->cookie;
|
$cookie = Factory::getApplication()->input->cookie;
|
||||||
$uue = $cookie->get('clubsLogin', '', 'raw');
|
$jsonValue = $cookie->get('clubsLogin', '', 'raw');
|
||||||
|
|
||||||
if($uue === '')
|
if($jsonValue === '')
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$jsonValue = convert_uudecode($uue);
|
|
||||||
|
|
||||||
$value = json_decode($jsonValue, true);
|
$value = json_decode($jsonValue, true);
|
||||||
|
|
||||||
|
if($value === null)
|
||||||
|
// Error in JSON code
|
||||||
|
return false;
|
||||||
|
|
||||||
$keys = $this->getKeys();
|
$keys = $this->getKeys();
|
||||||
$pubkey = openssl_pkey_get_public($keys['public']);
|
$pubkey = openssl_pkey_get_public($keys['public']);
|
||||||
$ret = openssl_verify(json_encode($value['auth']), convert_uudecode($value['sign']), $pubkey);
|
$ret = openssl_verify(json_encode($value['auth']), convert_uudecode($value['sign']), $pubkey);
|
||||||
|
Loading…
Reference in New Issue
Block a user