/** * * */ public function handleAuthenticationRequest(&$message, $conf) { if ($this->app->request()->isFormData() and !$this->app->request()->isXhr()) { if ($this->app->request()->post('username') and $this->app->request()->post('password')) { $username = $this->app->request()->post('username'); $pass = $this->app->request()->post('password'); $passCompare = $conf['raptor']['adminpass']; $obj = \Raptor\Configuration\ConfigurationLoader::getHash($passCompare); if ($obj->valid) { $passCompare = \Raptor\Security\SecureHash::verify($pass, $obj->password); } else { $passCompare = $pass === $conf['raptor']['adminpass']; } if ($conf['raptor']['admin'] == $username and $passCompare) { $this->app->getSession()->set('admin_auth', true); $this->app->getSession()->set('admin_auth_user', $username); $this->app->redirect(''); } else { $message = "Wrong password or username"; } } else { $message = "Wrong password or username"; } } }
/** * Redirecciona hacia el nombre de ruta especificado * * Podra redireccionarse por nombre de ruta o por URL, para * redireccionar a una URL el segundo parametro debera ser false * * @param string $routeName EL nombre de ruta de Raptor * @param boolean $isName Establece si el primer paremetro es un nombre de ruta o una URL, por defecto en true(nombre de ruta) * @param int $status Codigo de la redireccion * @throws \Exception */ public function redirect($routeName, $isName = true, $status = 302) { if ($isName == true) { $route = $this->app->router()->getNamedRoute($routeName); if ($route != NULL) { $this->app->redirect($this->app->request()->getScriptName() . $route->getPattern(), $status); } else { throw new \Exception("The route name ( {$routeName} ) do not exist", 3); } } else { $this->app->redirect($routeName, $status); } }
public function init(\Raptor\Raptor $app) { // Place your init code here /** * This make Raptor load the control panel from the root path * if the config mode is debug wich is taken by Raptor like * DEV mode * * PROBABLY YOU NEED TO REMOVE THIS IN PRODUCTION MODE */ if ($app->config('debug')) { $app->any('/', function () use($app) { $app->redirect($app->request()->getScriptName() . '/raptor'); }); } }