private function resolveCerts($user) { if (!empty($user['certs'])) { $certs = new certs(ConnectionFactory::get('mongo'), ConnectionFactory::get('redis')); foreach ($user['certs'] as $key => $certKey) { $user['certs'][$key] = openssl_x509_parse($certs->get($certKey), false); $user['certs'][$key]['certKey'] = $certKey; $user['certs'][$key]['subject']['organizationName'] = $this->clean($user['certs'][$key]['subject']['organizationName']); } } return $user; }
protected function certificate_remove() { // Delete if (!Session::isLoggedIn()) { return Error::set('You are not logged in!'); } if (empty($_POST['hash'])) { return Error::set('No certificate hash was found.'); } $certs = new certs(ConnectionFactory::get('mongo'), ConnectionFactory::get('redis')); $cert = $certs->get($_POST['hash'], false); if ($cert == null) { return Error::set('Invalid certificate hash.'); } if (substr($cert, 0, strpos($cert, ':')) != Session::getVar('_id')) { return Error::set('You are not allowed to remove this certificate.'); } $users = new users(ConnectionFactory::get('mongo')); $users->removeCert(Session::getVar('_id'), $_POST['hash']); $certs->removeCert($_POST['hash']); header('Location: ' . Url::format('/user/settings')); }