public function procede() { try { if ($this->oRequest->existParam('code')) { if (!$this->oRequest->existParam('password')) { throw new Error('Vous devez renseigner un password.', 1043); } if (!$this->oRequest->existParam('email')) { throw new Error('Vous devez renseigner une adresse email.', 1043); } if (!$this->oRequest->existParam('login')) { throw new Error('Vous devez renseigner un nom d\'utilisateur.', 1043); } $oInvite = new Invites(0, $this->oRequest->getParam('code', 'string')); if (!$oInvite->checkInvite()) { throw new Error('Votre code d\'invitation n\'est pas valide.', 1043); } $sPassword = $this->oRequest->getParam('password', 'string'); $sConfirmation = $this->oRequest->getParam('confirmation', 'string'); if ($sPassword != $sConfirmation) { throw new Error("Le password et la confirmation ne correspondent pas.", 1043); } $sPassword = User::cryptPassword($sPassword); $oUser = new User(0, $this->oRequest->getParam('login', 'string'), $sPassword, $this->oRequest->getParam('email', 'string'), md5(time() * rand())); $oUser->store(); //On demande au modèle de vérifier l'identification $this->oCurrentUser->loadFromFormular($this->oRequest->getParam('login', 'string'), $this->oRequest->getParam('password', 'string'), false); $oInvite->usedBy($this->oCurrentUser->getId()); Logger::log('admin', $this->oCurrentUser->getLogin() . ' a rejoint le site avec le code : ' . $this->oRequest->getParam('code', 'string')); $this->oView->addAlert("Redirection en cours ...", 'success'); header("Location: http://" . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . "/index.php"); } } catch (Error $e) { $this->oView->addAlert($e, 'danger'); } finally { $this->oView->Create(); } }