public function login()
 {
     //If the register form was sent
     if (Form::exists('restaurateur_login_form')) {
         //Check if User exists
         $user = Restaurateur::getOneBy(array('_mail' => Form::get('mail')));
         //Confirm if PW matches
         if ($user && $user->getPassword() == Restaurateur::encryptPassword(Form::get('password'))) {
             Session::connect($user);
             return Redirect::to('/restaurateur');
         }
         $error = "Vos informations de connexion sont incorrects. Merci de réessayer.";
         return View::render("restaurateur/login.php", array('error' => $error));
     }
     return View::render("restaurateur/login.php");
 }
Example #2
0
 public function index()
 {
     //If the register form was sent
     if (Form::exists('login_form')) {
         //Check if User exists
         $user = Client::getOneBy(array('_mail' => Form::get('mail')));
         //Confirm if PW matches
         if ($user && $user->getPassword() == Client::encryptPassword(Form::get('password'))) {
             Session::connect($user);
             return \App\Component\Redirect::to('/');
         }
         $error = "Vos informations de connexion sont incorrects. Merci de réessayer.";
         return View::render("login/index.php", array('error' => $error));
     }
     return View::render("index/index.php");
 }
Example #3
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));
 }