public function authentificationAction() { // On change le layout $this->layout('layout/login'); //Assignation de variables au layout $this->layout()->setVariables(array('headTitle' => $this->getServiceLocator()->get('Translator')->translate('S\'authentifier'), 'route' => 'application_login', 'action' => 'authentification', 'module' => 'application', 'plugins' => array())); $em = $this->getEntityManager(); $request = $this->getRequest(); $form = new AuthentificationForm(); $messageForm = null; if ($request->isPost()) { $form->setData($request->getPost()); if ($form->isValid()) { $email = $this->params()->fromPost('email'); $motDePasse = $this->params()->fromPost('mot_de_passe'); $personnel = new Personnel(); $personnels = $personnel->loadByEmailAndPassword($em, $email, md5($motDePasse)); if ($personnels) { //var_dump($infos);die(); $this->miseEnSessionUtilisateur($personnels[0], $email, $motDePasse); return $this->redirect()->toRoute('home'); } else { $messageForm = $this->getServiceLocator()->get('Translator')->translate('Identifiants invalides'); } } else { $messageForm = $this->getServiceLocator()->get('Translator')->translate('Vueillez ressaisir vos entrées'); } } return new ViewModel(array('form' => $form, 'messageForm' => $messageForm)); }
/** * {@inheritDoc} */ public function loadByEmailAndPassword($em = NULL, $email = '', $motDePasse = '') { $this->__initializer__ && $this->__initializer__->__invoke($this, 'loadByEmailAndPassword', array($em, $email, $motDePasse)); return parent::loadByEmailAndPassword($em, $email, $motDePasse); }