public function login()
 {
     //If the register form was sent
     if (Form::exists('entrepreneur_login_form')) {
         //Check if User exists
         $user = Entrepreneur::getOneBy(array('_mail' => Form::get('mail')));
         //Confirm if PW matches
         if ($user && $user->getPassword() == Entrepreneur::encryptPassword(Form::get('password'))) {
             Session::connect($user);
             return Redirect::to('/entrepreneur');
         }
         $error = "Vos informations de connexion sont incorrects. Merci de réessayer.";
         return View::render("entrepreneur/login.php", array('error' => $error));
     }
     return View::render("entrepreneur/login.php");
 }
Exemple #2
0
 /**
  * Seed the Database with Users
  */
 private function addUsers()
 {
     //Add the Entrepreneur if he doesn't exist
     if (!Entrepreneur::getOneBy(array('_mail' => "*****@*****.**"))) {
         $user = new Entrepreneur();
         $user->setFirstName("Bill");
         $user->setName("Gates");
         $user->setMail("*****@*****.**");
         $user->setPassword("123123");
         $user->save();
     }
     //Add a Restaurateur if he doesn't exist
     if (!Restaurateur::getOneBy(array('_mail' => "*****@*****.**"))) {
         $user = new Restaurateur();
         $user->setFirstName("MacDonald");
         $user->setName("Ronald");
         $user->setMail("*****@*****.**");
         $user->setPassword("123123");
         $user->save();
     }
     //Add a Restaurateur if he doesn't exist
     if (!Restaurateur::getOneBy(array('_mail' => "*****@*****.**"))) {
         $user = new Restaurateur();
         $user->setFirstName("Tiki");
         $user->setName("Ming");
         $user->setMail("*****@*****.**");
         $user->setPassword("123123");
         $user->save();
     }
     //Add a Restaurateur if he doesn't exist
     if (!Restaurateur::getOneBy(array('_mail' => "*****@*****.**"))) {
         $user = new Restaurateur();
         $user->setFirstName("Jean");
         $user->setName("Bono");
         $user->setMail("*****@*****.**");
         $user->setPassword("123123");
         $user->save();
     }
     //Add a Client if he doesn't exist
     $address = Address::getOneBy(array('address' => '18 Rue des Roses'));
     if (!$address) {
         $address = new Address();
         $address->setAddress('18 Rue des Roses');
         $address->save();
     }
     if (!Client::getOneBy(array('_mail' => "*****@*****.**"))) {
         $user = new Client();
         $user->setFirstName("Jean");
         $user->setName("Bon");
         $user->setMail("*****@*****.**");
         $user->setAddress($address);
         $user->setBirthday("10 Janvier 1973");
         $user->setPhoneNumber("593 489 2354");
         $user->setPassword("123123");
         $user->save();
         $address->setUser($user);
         $address->save();
     }
     //Add a Livreur if he doesn't exist
     if (!Livreur::getOneBy(array('_mail' => "*****@*****.**"))) {
         $user = new Livreur();
         $user->setFirstName("Jiang");
         $user->setName("Li");
         $user->setMail("*****@*****.**");
         $user->setPassword("123123");
         $user->save();
     }
 }