code = $data['code']; } public function shouldRequireEmailVerification() { // Since users need to be able to hit this endpoint in order to verify // email, we can't ever require email verification here. return false; } public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $email = id(new PhabricatorUserEmail())->loadOneWhere( 'userPHID = %s AND verificationCode = %s', $user->getPHID(), $this->code); $home_link = phutil_render_tag( 'a', array( 'href' => '/', ), 'Continue to Phabricator'); $home_link = '

'.$home_link.'

'; $settings_link = phutil_render_tag( 'a', array( 'href' => '/settings/page/email/', ), 'Return to Email Settings'); $settings_link = '

'.$settings_link.'

'; if (!$email) { $content = id(new AphrontErrorView()) ->setTitle('Unable To Verify') ->appendChild( '

The verification code is incorrect, the email address has '. 'been removed, or the email address is owned by another user. Make '. 'sure you followed the link in the email correctly.

'); } else if ($email->getIsVerified()) { $content = id(new AphrontErrorView()) ->setSeverity(AphrontErrorView::SEVERITY_NOTICE) ->setTitle('Address Already Verified') ->appendChild( '

This email address has already been verified.

'. $settings_link); } else { $guard = AphrontWriteGuard::beginScopedUnguardedWrites(); $email->setIsVerified(1); $email->save(); unset($guard); $content = id(new AphrontErrorView()) ->setSeverity(AphrontErrorView::SEVERITY_NOTICE) ->setTitle('Address Verified') ->appendChild( '

This email address has now been verified. Thanks!

'. $home_link. $settings_link); } return $this->buildStandardPageResponse( $content, array( 'title' => 'Verify Email', )); } }