public function testSetData() { $tools = new View\Tools(); $aCredentials = Model\Auth::getCredentials('test_user'); //var_dump($aCredentials); $this->assertEquals($tools->render(), '<strong>Tools</strong>'); }
public function testSetData() { $aCredentials = Model\Auth::loginByCredentials('fer', 'fer', false); $this->assertTrue(Model\Auth::loginByCredentials('test_user', 'fer', false)); //$this->assertTrue(Model\Auth::loginByCredentials('Fer', 'fer', true)); $this->assertFalse(Model\Auth::loginByCredentials('bad_test_user', 'fer', false)); $this->assertTrue(Model\Auth::loginByPersintence('test_user', '940e9aac0d740736b18be249a04e518343855a5a')); $this->assertFalse(Model\Auth::loginByPersintence('fer', 'fer')); }
<?php namespace Acd; require '../autoload.php'; $returnUrl = 'index.php'; //session_start(); Model\Auth::logout(); header("Location:{$returnUrl}");
return $app->redirect($app['url_generator']->generate('account')); })->bind('done'); $app->get('/task/delete/{id}', function ($id) use($app) { if (null === $app['session']->get('session_login')) { return $app['twig']->render('auth/form.twig', ['errorMessage' => 'You should authenticate first']); } $task = new Task($app['pdo']); $task->delete($id); return $app->redirect($app['url_generator']->generate('account')); })->bind('delete'); $app->get('/task/remove/{id}', function ($id) use($app) { if (null === $app['session']->get('session_login')) { return $app['twig']->render('auth/form.twig', ['errorMessage' => 'You should authenticate first']); } $task = new Task($app['pdo']); $task->remove($id); return $app->redirect($app['url_generator']->generate('account')); }); $app->post('/auth', function () use($app) { $login = $app['request']->get('login'); $pass = $app['request']->get('pass'); $auth = new \Model\Auth($app['pdo']); if ($auth->isUserFound($login, $pass)) { $app['session']->set('session_login', $login); return $app->redirect($app['url_generator']->generate('account')); } else { return $app['twig']->render('auth/form.twig', ['errorMessage' => 'Wrong login or password!']); } }); // party should go on :) $app->run();
require '../autoload.php'; session_start(); function loadNewRef($idRef, $idStructure) { if (!$idRef || !$idStructure) { return null; } $contentLoader = new Model\ContentLoader(); $contentLoader->setId($idStructure); $content = $contentLoader->loadContents('id', $idRef); //$contents = new Model\ContentsDo(); //$contents->add($content); return $content; } $action = isset($_GET['a']) ? $_GET['a'] : 'list_structures'; if (!Model\Auth::isLoged()) { $action = 'login'; } switch ($action) { case 'login': header('Location: index.php'); return; break; case 'list_structures': $structures = new Model\StructuresDo(); $structures->loadFromFile(conf::$DATA_PATH); $headerMenuOu = new View\HeaderMenu(); $headerMenuOu->setType('menu'); $toolsOu = new View\Tools(); $toolsOu->setLogin($_SESSION['login']); $toolsOu->setRol($_SESSION['rol']);