Exemplo n.º 1
0
 public function register()
 {
     $data = Request::all();
     // Si tous les champs ont été remplis
     if (!Validator::array_has_empty($data)) {
         // Si le password et la confirmation sont identiques
         if ($data['password'] == $data['password2']) {
             // Si l'email existe déjà dans la db -> erreur
             if ($this->User->findByMail($data['mail'])) {
                 $this->setFlash("This email is already used", 'warning');
                 $this->view->render('users/register');
             } else {
                 $this->User->save($data);
                 $_SESSION['user'] = $data;
                 $_SESSION['user']['role'] = "member";
                 unset($_SESSION['user']['password'], $_SESSION['user']['password2']);
                 $this->setFlash("You are successfully registered", 'success');
                 //$this->login();
                 $this->view->redirect_to('user/index');
             }
         } else {
             $this->setFlash("Not same passwords", 'warning');
             $this->view->render('users/register');
         }
     } elseif ($data && Validator::array_has_empty($data)) {
         $this->setFlash("Please fill all the fields", 'warning');
         $this->view->render('users/register');
     } else {
         $this->view->render('users/register');
     }
 }
Exemplo n.º 2
0
 /**
  * Register container bindings for the application.
  *
  * @return void
  */
 protected function registerValidationBindings()
 {
     $this->singleton('validator', function () {
         $validator = new Validator($this);
         return $validator->setConnection(app('capsule')->getDatabaseManager());
         // return new Validator;
     });
 }