public function validate(\Nethgui\Controller\ValidationReportInterface $report) { parent::validate($report); if ($this->getRequest()->isMutation()) { $v = new \NethServer\Tool\PamValidator(); $v->setLog($this->getLog()); $v->setPhpWrapper($this->getPhpWrapper()); if (!$v->evaluate(array($this->getRequest()->getUser()->getCredential('username'), $this->parameters['oldPassword']))) { $report->addValidationError($this, 'oldPassword', $v); } } }
$loader = new \Composer\Autoload\ClassLoader(); $loader->add('Nethgui', $nsbase); $loader->add('NethServer', $nsbase); $loader->register(); foreach ($loader->getPrefixes() as $nsName => $paths) { $namespaces[trim($nsName, '\\')] = reset($paths) . DIRECTORY_SEPARATOR . trim($nsName, '\\'); } $loader->add('Pimple', $nsbase); $loader->add('Mustache', $nsbase); $loader->add('Symfony', $nsbase); $FW = new \Nethgui\Framework(); $FW->setLogLevel(E_WARNING | E_ERROR | E_NOTICE)->registerNamespace($namespaces[__NAMESPACE__])->setDefaultModule('Dashboard')->setDecoratorTemplate('NethServer\\Template\\NethServer')->setForcedLoginModule(function ($dc) { return $dc['Platform']->getDatabase('configuration')->getProp('httpd-admin', 'ForcedLoginModule'); })->setAuthenticationValidator(function ($dc) { $v = new \NethServer\Tool\PamValidator(); $v->setLog($dc['Log']); return $v; }); try { $R = $FW->createRequest(); if ($R->getFormat() === 'xhtml') { $R->setParameter('Menu', array())->setParameter('Tracker', array())->setParameter('Notification', array())->setParameter('Resource', array())->setParameter('Logout', array()); } elseif ($R->getFormat() === 'json') { $R->setParameter('Tracker', array())->setParameter('Notification', array()); } $FW->dispatch($R); } catch (\Nethgui\Exception\HttpException $ex) { $FW->printHttpException($ex, TRUE); } catch (\Exception $ex) { $FW->printHttpException(new \Nethgui\Exception\HttpException('Internal server error', 500, 1377609335, $ex), TRUE); }