public function actionSignup(User $user, CSRF $CSRF, Session $session, Mail $mail) { if ($user->isLogged()) { $placeholders['content'] = $this->getMessageLogout($CSRF, 'signupLogout'); return $this->render('success', $placeholders); } if (($message = $session->getFlash($this->keySessionFlash)) && isset($message['email'])) { $placeholders['content'] = $this->template->getChunk('@common.views/elements/alert-success', ['output' => i18n::t($this->keySessionFlash, ['email' => $message['email']])]); return $this->render('success', $placeholders); } $model = new SignupForm(); // redirect Event::on($model, SignupForm::EVENT_AFTER_SIGNUP, function (ModelEvent $event) use($session, $mail, $model) { $this->sendMail($mail, $event->result, $model); $session->setFlash('successSignup', ['email' => $event->result->email]); $this->response->refresh()->send(true); }); $model->load($_POST); $placeholders['model'] = $model; return $this->render('index.php', $placeholders); }
/** * Returns code a captcha and remove session. * @return string|null */ public function getAndRemoveSession() { $result = $this->session->getFlash($this->sessionKey); $this->removeSession(); return $result; }
/** * Returns code of captcha and remove session. * * @param string|null $name * @return string|null */ public function getAndRemoveSession($name = null) { $name = Helper::getValue($name, $this->sessionName); $result = $this->session->getFlash($name); $this->removeSession($name); return $result; }