diff --git a/src/site/helpers/auth.php b/src/site/helpers/auth.php index 6fd944c..1489488 100644 --- a/src/site/helpers/auth.php +++ b/src/site/helpers/auth.php @@ -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);