Removed unneeded base64 encoding and added code to cope with wrong fromed JSON code

This commit is contained in:
Christian Wolf 2019-04-07 16:33:48 +02:00
parent 628514eb4e
commit ed87808391

View File

@ -38,7 +38,6 @@ class ClubsHelperAuth
$value['sign'] = convert_uuencode($signature);
$jsonValue = json_encode($value);
$uue = convert_uuencode($jsonValue);
$c = Factory::getApplication()->input->cookie;
if(! $keep)
@ -51,20 +50,23 @@ class ClubsHelperAuth
$time = time() + 3600*24*15;
$c->set('clubsLoginKeepLoggedIn', 'true', time() + 3600*24*356*10);
}
$c->set('clubsLogin', $uue, $time);
$c->set('clubsLogin', $jsonValue, $time);
}
public function checkCookie()
{
$cookie = Factory::getApplication()->input->cookie;
$uue = $cookie->get('clubsLogin', '', 'raw');
$jsonValue = $cookie->get('clubsLogin', '', 'raw');
if($uue === '')
if($jsonValue === '')
return false;
$jsonValue = convert_uudecode($uue);
$value = json_decode($jsonValue, true);
if($value === null)
// Error in JSON code
return false;
$keys = $this->getKeys();
$pubkey = openssl_pkey_get_public($keys['public']);
$ret = openssl_verify(json_encode($value['auth']), convert_uudecode($value['sign']), $pubkey);