Beispiel #1
0
 public function index()
 {
     //If the register form was sent
     if (Form::exists('register_form')) {
         //We check if all the input are filled
         if (Form::checkEmpty(array('mainAddress', 'firstName', 'mail', 'name', 'password', 'password_check', 'phoneNumber', 'birthday'))) {
             $error = "Veuillez remplir tous les champs";
             return View::render("register/index.php", array('error' => $error));
         }
         //We check if the mail address is not already taken
         if (Client::getOneBy(array('_mail' => Form::get('mail')))) {
             $error = "Cette adresse e-mail est déjà associée à un compte. Veuillez en choisir une autre.";
             return View::render("register/index.php", array('error' => $error));
         }
         //We check if the password and the check are the same
         if (Form::get('password') != Form::get('password_check')) {
             $error = "Les mots de passe ne correspondent pas.";
             return View::render("register/index.php", array('error' => $error));
         }
         //We create a new User, and associate the values
         $user = new Client();
         $user->setFirstName(Form::get('firstName'));
         $user->setMail(Form::get('mail'));
         $user->setName(Form::get('name'));
         $user->setPassword(Form::get('password'));
         $user->setPhoneNumber(Form::get('phoneNumber'));
         $user->setBirthday(Form::get('birthday'));
         //We save this User in the DB
         $user->save();
         $address = new \App\Model\Address();
         $address->setAddress(Form::get('mainAddress'));
         $address->setUser($user);
         $address->save();
         $user->setAddress($address);
         $user->save();
         return View::render("register/complete.php", array('user' => $user));
     }
     return View::render("register/index.php");
 }
Beispiel #2
0
 public function index()
 {
     //If the register form was sent
     if (Form::exists('profile_form')) {
         //We check if all the input are filled
         if (Form::checkEmpty(array('mainAddress', 'firstName', 'mail', 'name', 'password', 'password_check', 'phoneNumber', 'birthday'))) {
             $error = "Veuillez remplir tous les champs";
             return View::render("register/index.php", array('error' => $error));
         }
         $user = Session::getUser();
         //We check if the password and the check are the same
         if (Form::exists('password') && Form::get('password') != "") {
             if (Form::get('password') != Form::get('password_check')) {
                 $error = "Les mots de passe ne correspondent pas.";
                 return View::render("register/index.php", array('error' => $error));
             } else {
                 $user->setPassword(Form::get('password'));
             }
         }
         //associate the values
         $user->setFirstName(Form::get('firstName'));
         $user->setName(Form::get('name'));
         $user->setPhoneNumber(Form::get('phoneNumber'));
         $user->setBirthday(Form::get('birthday'));
         //We save this User in the DB
         $user->save();
         $adress = new \App\Model\Address();
         $adress->setAddress(Form::get('mainAddress'));
         $adress->setUser($user);
         $adress->save();
         $user->setAddress($adress);
         $user->save();
         Session::connect($user);
         return View::render("profile/complete.php", array('user' => $user));
     }
     $user = Session::getUser();
     return View::render("profile/index.php", array('user' => $user));
 }