Пример #1
0
 public function sign_in()
 {
     $this->setTitle("Sign in");
     //todo redirect if logged
     $authHandler = Application::getInstance()->authenticationHandler;
     $f = new Form('signin');
     if ($f->isValid()) {
         $data = $f->getValues();
         $authHandlerInst = call_user_func_array(array($authHandler, 'getInstance'), array());
         if ($authHandlerInst->setUserSession($data["login_user"], $data["password_user"])) {
             Go::to();
         } else {
             Logs::write("Tentative de connexion au front <" . $data["login_user"] . ":" . $data["password_user"] . ">", Logs::WARNING);
             $this->addContent("error", "Le login ou le mot de passe est incorrect");
         }
     } else {
         trace("aaaah");
         trace($f->getError());
         $this->addContent('error', $f->getError());
     }
     $this->addForm('sign_in', $f);
 }
Пример #2
0
 public function password()
 {
     $this->setTitle('Change your password - Savely.co');
     $f = new Form('password');
     if ($f->isValid()) {
         $v = $f->getValues();
         if (ModelAuthentication::getInstance()->changePassword($v['currentPassword'], $v['newPassword'])) {
             AuthenticationHandler::unsetUserSession();
             AuthenticationHandler::setUserSession(ModelAuthentication::getInstance()->getLogin(), $v['newPassword']);
             $this->addContent('confirmation', 'New Password Saved');
         } else {
             $this->addContent('error', 'You current password does not match');
         }
     } else {
         $this->addContent('error', $f->getError());
     }
     $this->addForm('password', $f);
 }
Пример #3
0
 public function share()
 {
     Autoload::addComponent("Achilles.share");
     $this->setTitle("Submit a link");
     /** @var AuthenticationHandler $auth */
     $auth = Application::getInstance()->authenticationHandler;
     if (!$auth::is(AuthenticationHandler::USER)) {
         Go::to404();
     }
     $m = new ModelPost();
     $form = new Form("post_share");
     if ($form->isValid()) {
         $v = $form->getValues();
         $insertedPermalink = $m->share($v);
         Header::location('post/' . $insertedPermalink);
     } else {
         $this->addContent("error", $form->getError());
     }
     $this->addForm("share", $form);
 }
 /**
  * Méthode de modification d'une entrée
  * Récup&egrave;re les données via le model et les injecte dans le formulaire
  * @return boolean
  */
 public function edit()
 {
     if (!$this->actions->isEnabled('edit')) {
         Go::to404();
     }
     $this->setTitle($this->titles->get('edit'));
     try {
         $form = new Form($this->formName);
     } catch (Exception $e) {
         $form = new Form($this->formName, false);
         $inputs = $this->model->generateInputsFromDescribe();
         foreach ($inputs as $nam => $inp) {
             $form->setInput($nam, $inp);
         }
     }
     $data = $this->model->getTupleById($_GET["id"]);
     if (!$data) {
         Go::to($this->className);
     }
     $form->injectValues($data);
     if ($form->isValid()) {
         if ($this->model->updateById($_GET["id"], $form->getValues())) {
             $this->addContent("confirmation", Dictionary::term("backoffice.forms.editDone"));
             $this->dispatchEvent(new Event(self::EVENT_SUCCESSFUL_EDIT));
         } else {
             $this->addContent("error", Dictionary::term("backoffice.forms.errorSQL"));
             $this->dispatchEvent(new Event(self::EVENT_FAILED_EDIT));
         }
         $id = $_GET["id"];
         $form->setUploadFileName($id);
     } else {
         $this->addContent("error", $form->getError());
     }
     $this->setTemplate("default", "form");
     $this->addContent("id", $this->model->id);
     $this->addForm("instance", $form);
     $this->addContent("h1", $this->h1->get('edit'));
 }