public static function onConfirmEmailShowRequestForm(EmailConfirmation &$pageObj, &$show)
 {
     $show = false;
     if (Sanitizer::validateEmail($pageObj->getUser()->getEmail())) {
         $userLoginHelper = new UserLoginHelper();
         $userLoginHelper->showRequestFormConfirmEmail($pageObj);
     } else {
         $pageObj->getOutput()->addWikiMsg('usersignup-user-pref-confirmemail_noemail');
     }
     return true;
 }
예제 #2
0
 /**
  * Show a nice form for the user to request a confirmation mail
  * original function: showRequestForm() in EmailConfirmation class (Special:Confirmemail page)
  *
  * @param EmailConfirmation $pageObj
  */
 public function showRequestFormConfirmEmail(EmailConfirmation $pageObj)
 {
     $user = $pageObj->getUser();
     /* @var $user User */
     $out = $pageObj->getOutput();
     /* @var $out OutputPage */
     $optionNewEmail = $user->getGlobalAttribute('new_email');
     if ($pageObj->getRequest()->wasPosted() && $user->matchEditToken($pageObj->getRequest()->getText('token'))) {
         // Wikia change -- only allow one email confirmation attempt per hour
         if (strtotime($user->mEmailTokenExpires) - strtotime("+6 days 23 hours") > 0) {
             $out->addWikiMsg('usersignup-error-throttled-email');
             return;
         }
         $email = $user->isEmailConfirmed() && !empty($optionNewEmail) ? $optionNewEmail : $user->getEmail();
         $status = $this->sendReconfirmationEmail($user, $email);
         if ($status->isGood()) {
             $out->addWikiMsg('usersignup-user-pref-reconfirmation-email-sent', $email);
         } else {
             $out->addWikiText($status->getWikiText('userlogin-error-mail-error'));
         }
     } else {
         if ($user->isEmailConfirmed() && empty($optionNewEmail)) {
             // date and time are separate parameters to facilitate localisation.
             // $time is kept for backward compat reasons.
             // 'emailauthenticated' is also used in SpecialPreferences.php
             $lang = $pageObj->getLanguage();
             $emailAuthenticated = $user->getEmailAuthenticationTimestamp();
             $time = $lang->timeAndDate($emailAuthenticated, $user);
             $d = $lang->date($emailAuthenticated, $user);
             $t = $lang->time($emailAuthenticated, $user);
             $out->addWikiMsg('usersignup-user-pref-emailauthenticated', $time, $d, $t);
             return;
         }
         if ($user->isEmailConfirmationPending() || !empty($optionNewEmail)) {
             $out->addWikiMsg('usersignup-confirm-email-unconfirmed-emailnotauthenticated');
             if (strtotime($user->mEmailTokenExpires) - strtotime("+6 days 23 hours") > 0) {
                 return;
             }
         }
         $form = Xml::openElement('form', array('method' => 'post', 'action' => $pageObj->getTitle()->getLocalUrl()));
         $form .= Html::hidden('token', $user->getEditToken());
         $form .= Xml::submitButton($pageObj->msg('usersignup-user-pref-confirmemail_send')->text());
         $form .= Xml::closeElement('form');
         $out->addHTML($form);
     }
 }
예제 #3
0
 private function send_confirmation_email()
 {
     // TODO : Make sure this is the right way to do this
     if (!$this->logged_in) {
         return false;
     }
     $this->load->library('email');
     $this->load->helper('keygen');
     // Grab logged in user
     $user = new User($this->user_id);
     // Check for existing confirmation
     $check = $user->emailconfirmation;
     $check->get();
     if ($check->exists()) {
         $econf = $check;
     } else {
         // Create a new EmailConfirmation
         $econf = new EmailConfirmation();
         $econf->code = keygen_generate(32);
         $econf->email = $user->email;
         $econf->save($user);
     }
     $this->user_session->updateValidation();
     $data['user'] = array('firstname' => $user->firstname, 'lastname' => $user->lastname);
     $data['link'] = base_url('users/confirm_account') . '?email=' . urlencode($user->email) . '&confirm_code=' . urlencode($econf->code);
     $data['content'] = 'users/confirmation_email';
     $message = $this->load->view('email_master', $data, TRUE);
     $this->email->from('*****@*****.**', 'OurVigor Support');
     $this->email->to($user->email);
     $this->email->subject('OurVigor Confirmation Email');
     $this->email->message($message);
     $this->email->send();
     return TRUE;
 }
예제 #4
0
/**
 * Main execution point
 *
 * @param $par Parameters passed to the page
 */
function wfSpecialConfirmemail($par)
{
    $form = new EmailConfirmation();
    $form->execute($par);
}
    $returnValue["message"] = "Please choose a different email address";
    echo json_encode($returnValue);
    return;
}
// Register new user
$result = $dao->registerUser($userEmail, $userFirstName, $userLastName, $secured_password, $salt);
if ($result) {
    $userDetails = $dao->getUserDetails($userEmail);
    $returnValue["status"] = "200";
    $returnValue["message"] = "Successfully registered new user";
    $returnValue["userId"] = $userDetails["user_id"];
    $returnValue["userFirstName"] = $userDetails["first_name"];
    $returnValue["userLastName"] = $userDetails["last_name"];
    $returnValue["userEmail"] = $userDetails["email"];
    // Generate a unique email confirmation token
    $emailConfirmation = new EmailConfirmation();
    $emailToken = $emailConfirmation->generateUniqueToken(16);
    // Store email token in our database table.
    $dao->storeEmailToken($userDetails["user_id"], $emailToken);
    // Prepare email message parameters like Subject, Message, From, To and etc.
    $messageDetails = array();
    $messageDetails["message_subject"] = "Please confirm your email address";
    $messageDetails["to_email"] = $userDetails["email"];
    $messageDetails["from_name"] = "Sergey Kargopolov";
    $messageDetails["from_email"] = "*****@*****.**";
    // Load up email message from an email template
    $emailMessage = $emailConfirmation->loadEmailEmailMessage();
    $emailMessage = str_replace("{token}", $emailToken, $emailMessage);
    $messageDetails["message_body"] = $emailMessage;
    // Send out this email message to user
    $emailConfirmation->sendEmailConfirmation($messageDetails);