Path: blob/master/src/applications/auth/controller/PhabricatorEmailVerificationController.php
12256 views
<?php12final class PhabricatorEmailVerificationController3extends PhabricatorAuthController {45public function shouldRequireEmailVerification() {6// Since users need to be able to hit this endpoint in order to verify7// email, we can't ever require email verification here.8return false;9}1011public function shouldRequireEnabledUser() {12// Unapproved users are allowed to verify their email addresses. We'll kick13// disabled users out later.14return false;15}1617public function handleRequest(AphrontRequest $request) {18$viewer = $this->getViewer();19$code = $request->getURIData('code');2021if ($viewer->getIsDisabled()) {22// We allowed unapproved and disabled users to hit this controller, but23// want to kick out disabled users now.24return new Aphront400Response();25}2627$email = id(new PhabricatorUserEmail())->loadOneWhere(28'userPHID = %s AND verificationCode = %s',29$viewer->getPHID(),30$code);3132$submit = null;3334if (!$email) {35$title = pht('Unable to Verify Email');36$content = pht(37'The verification code you provided is incorrect, or the email '.38'address has been removed, or the email address is owned by another '.39'user. Make sure you followed the link in the email correctly and are '.40'logged in with the user account associated with the email address.');41$continue = pht('Rats!');42} else if ($email->getIsVerified() && $viewer->getIsEmailVerified()) {43$title = pht('Address Already Verified');44$content = pht(45'This email address has already been verified.');46$continue = pht('Continue');47} else if ($request->isFormPost()) {4849id(new PhabricatorUserEditor())50->setActor($viewer)51->verifyEmail($viewer, $email);5253$title = pht('Address Verified');54$content = pht(55'The email address %s is now verified.',56phutil_tag('strong', array(), $email->getAddress()));57$continue = pht('Continue');58} else {59$title = pht('Verify Email Address');60$content = pht(61'Verify this email address (%s) and attach it to your account?',62phutil_tag('strong', array(), $email->getAddress()));63$continue = pht('Cancel');64$submit = pht('Verify %s', $email->getAddress());65}6667$dialog = id(new AphrontDialogView())68->setUser($viewer)69->setTitle($title)70->addCancelButton('/', $continue)71->appendChild($content);7273if ($submit) {74$dialog->addSubmitButton($submit);75}7677$crumbs = $this->buildApplicationCrumbs();78$crumbs->addTextCrumb(pht('Verify Email'));79$crumbs->setBorder(true);8081return $this->newPage()82->setTitle(pht('Verify Email'))83->setCrumbs($crumbs)84->appendChild($dialog);8586}8788}899091