Esempio n. 1
0
 public function action_log()
 {
     $user = $this->is_logged();
     if ($user === false) {
         $try = new User_lif();
         $try->set_username_user_lif($_POST['user']);
         $try->set_password_user_lif($_POST['pw']);
         $this->_id = $try->attempt();
         if ($this->_id) {
             $user = new User_lif();
             $user->set_id_user_lif($this->_id);
             $user->load();
             Session::put('user', $user);
             return Redirect::to_action('home@index');
         }
         $this->_error_form = "Identifiant ou mot de passe éronné, veuillez réessayer svp.";
         return Redirect::to_action('login')->with('error_msg', $this->_error_form);
     }
 }
Esempio n. 2
0
 public function action_add_user()
 {
     if ($_POST['user'] != "") {
         $this->_username = $_POST['user'];
     } else {
         $this->_error_form = true;
     }
     if ($_POST['name'] != "" and $this->_error_form == false) {
         $this->_name = $_POST['name'];
     } else {
         $this->_error_form = true;
     }
     if ($_POST['fname'] != "" and $this->_error_form == false) {
         $this->_fname = $_POST['fname'];
     } else {
         $this->_error_form = true;
     }
     if ($_POST['pw'] != "" and $this->_error_form == false) {
         $this->_password = Hash::make($_POST['pw']);
     } else {
         $this->_error_form = true;
     }
     if ($this->_error_form == true) {
         $this->_client_msg = "Veuillez remplir tous les champs svp";
         return Redirect::to_action('signin')->with('error_msg', $this->_client_msg);
     } else {
         $user = new User_lif(null, $this->_username, $this->_password, $this->_name, $this->_fname, null);
         if ($user->check_exists() == false and $this->_error_form == false) {
             $user->set_id_user_lif($user->add());
             $user->load();
             Session::put('user', $user);
             $this->_client_msg = "Enregistrement réussi ! Bienvenue" . $this->_username;
             return Redirect::to_action('home@index');
         } else {
             $this->_client_msg = "Le nom d'utilisteur est déjà utilisé. Veuillez en saisir un nouveau.";
             return Redirect::to_action('signin')->with('error_msg', $this->_client_msg);
         }
     }
 }