public function signuppostAction() { if ($data = $this->getRequest()->getPost()) { try { // Check l'email et le mot de passe if (empty($data['email']) or !Zend_Validate::is($data['email'], 'emailAddress')) { throw new Exception($this->_('Please enter a valid email address.')); } if (empty($data['password']) or strlen($data['password']) < 6) { throw new Exception($this->_('The password must be at least 6 characters.')); } if (empty($data['confirm_password']) or $data['password'] != $data['confirm_password']) { throw new Exception($this->_('The password and the confirmation does not match.')); } $admin = new Admin_Model_Admin(); $admin->findByEmail($data['email']); if ($admin->getId()) { throw new Exception($this->_('We are sorry but this email address is already used.')); } $role = new Acl_Model_Role(); if ($default_role = $role->findDefaultRoleId()) { $admin->setRoleId($default_role); } // Créé le user $admin->setEmail($data['email'])->setPassword($data['password'])->save(); // Met le user en session $this->getSession()->setAdmin($admin); $admin->sendAccountCreationEmail($data["password"]); $redirect_to = 'admin/application/list'; } catch (Exception $e) { if ($this->getSession()->isLoggedIn()) { $redirect_to = 'admin/application/list'; } else { $this->getSession()->addError($e->getMessage()); $redirect_to = "/"; } } $this->redirect($redirect_to); } }