/** * Adds a new user account and sends a confirmation email. * * @return User an instance of User on success; null otherwise. * @throws PermissionsError * @throws ReadOnlyError */ public function addNewAccount() { $u = $this->addNewAccountInternal(); if ($u instanceof User) { // send confirmation email $userLoginHelper = new UserLoginHelper(); $result = $userLoginHelper->sendConfirmationEmail($this->mUsername); $this->mainLoginForm($result['msg'], $result['result']); } return $u; }
/** * @brief send confirmation email * @resquestParam string username * @resquestParam boolean byemail * @responseParam string result [ok/error/invalidsession/confirmed] * @responseParam string msg - result message * @responseParam string msgEmail * @responseParam string errParam * @responseParam string heading * @responseParam string subheading */ public function sendConfirmationEmail() { if ($this->request->getVal('format', '') !== 'json') { $this->wg->Out->setPageTitle(wfMessage('usersignup-confirm-page-title')->plain()); $this->response->addAsset('extensions/wikia/UserLogin/css/UserSignup.scss'); $this->response->addAsset('extensions/wikia/UserLogin/css/ConfirmEmail.scss'); $this->response->addAsset('extensions/wikia/UserLogin/js/ConfirmEmail.js'); // hide things in the skin $this->wg->SuppressWikiHeader = true; $this->wg->SuppressPageHeader = true; $this->wg->SuppressFooter = true; $this->wg->SuppressAds = true; $this->wg->SuppressToolbar = true; } $this->username = $this->request->getVal('username', ''); $this->byemail = $this->request->getBool('byemail', false); // default heading, subheading, msg // depending on what happens, default will be over written below $mailTo = $this->username; $user = User::newFromName($this->username); if ($user instanceof User && $user->getID() != 0) { if (isset($_SESSION['notConfirmedUserId']) && $_SESSION['notConfirmedUserId'] == $user->getId()) { $mailTo = $user->getEmail(); } } else { // Redirect back to login if we didn't get a valid user $titleObj = SpecialPage::getTitleFor('Userlogin'); $this->wg->out->redirect($titleObj->getFullURL()); return; } $this->result = 'ok'; $mailTo = htmlspecialchars($mailTo); if (F::app()->checkskin('wikiamobile')) { $this->msg = wfMessage('usersignup-confirmation-email-sent-wikiamobile')->rawParams($mailTo)->parse(); $this->overrideTemplate('WikiaMobileSendConfirmationEmail'); $this->wg->Out->setPageTitle(wfMessage('usersignup-confirm-page-title-wikiamobile')->plain()); } else { $this->heading = wfMessage('usersignup-confirmation-heading')->escaped(); $this->subheading = wfMessage('usersignup-confirmation-subheading')->escaped(); $this->msg = wfMessage('usersignup-confirmation-email-sent')->rawParams($mailTo)->parse(); $this->msgEmail = ''; $this->errParam = ''; if ($this->wg->Request->wasPosted()) { $action = $this->request->getVal('action', ''); if ($action == 'resendconfirmation') { $response = $this->userLoginHelper->sendConfirmationEmail($this->username); $this->result = $response['result']; $this->msg = $response['msg']; $this->heading = wfMessage('usersignup-confirmation-heading-email-resent')->escaped(); } else { if ($action == 'changeemail') { $this->email = $this->request->getVal('email', ''); $params = ['username' => $this->username, 'email' => $this->email]; $response = $this->sendSelfRequest('changeUnconfirmedUserEmail', $params); $this->result = $response->getVal('result', ''); if ($this->result == 'ok') { $this->msg = $response->getVal('msg', ''); $this->heading = wfMessage('usersignup-confirmation-heading-email-resent')->escaped(); } else { if ($this->result == 'error') { $this->msgEmail = $response->getVal('msg', ''); $this->errParam = $response->getVal('errParam', ''); } else { if ($this->result == 'confirmed') { $this->heading = wfMessage('usersignup-confirm-page-heading-confirmed-user')->escaped(); $this->subheading = wfMessage('usersignup-confirm-page-subheading-confirmed-user')->escaped(); $this->msg = $response->getVal('msg', ''); } } } } } // redirect to login page if invalid session if ($this->result == 'invalidsession') { $titleObj = SpecialPage::getTitleFor('Userlogin'); $this->wg->out->redirect($titleObj->getFullURL()); return; } } else { if ($this->byemail == true) { $this->heading = wfMessage('usersignup-account-creation-heading')->escaped(); $this->subheading = wfMessage('usersignup-account-creation-subheading')->rawParams($mailTo)->escaped(); $this->msg = wfMessage('usersignup-account-creation-email-sent')->rawParams($mailTo, htmlspecialchars($this->username))->parse(); } } } }
/** * Send a confirmation email to the user. This is used when the user doesn't * have an email registered with Facebook and provides us one in the signup form. */ private function sendConfirmationEmail() { $userLoginHelper = new UserLoginHelper(); $userLoginHelper->sendConfirmationEmail($this->mUsername); }