/** * default constructor */ function __construct() { try { $popup = Input::session(self::SESSION_KEY); } catch (InputNotSetException $e) { } if (!empty($popup)) { $this->popup = $popup; } }
public function validate($inputs) { $result = []; foreach ($this->getFields() as $field) { if (array_key_exists($field->getName(), $inputs)) { if ($this->getMethod() == 'POST') { $result[$field->getName()] = Input::post($field->getName()); } elseif ($this->getMethod() == 'GET') { $result[$field->getName()] = Input::get($field->getName()); } } } return $result; }
public function connect() { try { $username = Input::post('username'); $password = sha1(Input::post('password')); $userModel = new UsersModel(); $result = $userModel->connect($username, $password)[0]['LOL']; if ($result != 1) { throw new \Exception('Les identifiants ne sont pas valides'); } else { $infos = $userModel->getInfos($username)[0]; $informations = new \stdClass(); $informations->firstname = $infos['firstname']; $informations->lastname = $infos['lastname']; $informations->username = $username; Authentication::getInstance()->setAuthenticated($username, $infos['id']); $response = new AJAXAnswer(true, $informations); $response->answer(); } } catch (InputNotSetException $e) { $error = new AJAXAnswer(false, 'Un champ est manquant'); $error->answer(); } catch (\Exception $e) { $error = new AJAXAnswer(false, $e->getMessage()); $error->answer(); } }