1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-01 03:02:43 +01:00
phorge-phorge/src/applications/legalpad/controller/LegalpadDocumentSignatureVerificationController.php
epriestley 46d9bebc84 Remove all device = true from page construction
Summary: Fixes T5446. Depends on D9687.

Test Plan: Mostly regexp'd this. Lint doesn't complain.

Reviewers: chad

Reviewed By: chad

Subscribers: epriestley, hach-que

Maniphest Tasks: T5446

Differential Revision: https://secure.phabricator.com/D9690
2014-06-23 15:18:14 -07:00

93 lines
2.6 KiB
PHP

<?php
final class LegalpadDocumentSignatureVerificationController
extends LegalpadController {
private $code;
public function willProcessRequest(array $data) {
$this->code = $data['code'];
}
public function shouldRequireEmailVerification() {
return false;
}
public function shouldRequireLogin() {
return false;
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
// this page can be accessed by not logged in users to valid their
// signatures. use the omnipotent user for these cases.
if (!$user->isLoggedIn()) {
$viewer = PhabricatorUser::getOmnipotentUser();
} else {
$viewer = $user;
}
$signature = id(new LegalpadDocumentSignatureQuery())
->setViewer($viewer)
->withSecretKeys(array($this->code))
->executeOne();
if (!$signature) {
$title = pht('Unable to Verify Signature');
$content = pht(
'The verification code you provided is incorrect or the signature '.
'has been removed. '.
'Make sure you followed the link in the email correctly.');
$uri = $this->getApplicationURI();
$continue = pht('Rats!');
} else {
$document = id(new LegalpadDocumentQuery())
->setViewer($user)
->withPHIDs(array($signature->getDocumentPHID()))
->executeOne();
// the document could be deleted or have its permissions changed
// 4oh4 time
if (!$document) {
return new Aphront404Response();
}
$uri = '/'.$document->getMonogram();
if ($signature->isVerified()) {
$title = pht('Signature Already Verified');
$content = pht(
'This signature has already been verified.');
$continue = pht('Continue to Legalpad Document');
} else {
$guard = AphrontWriteGuard::beginScopedUnguardedWrites();
$signature
->setVerified(LegalpadDocumentSignature::VERIFIED)
->save();
unset($guard);
$title = pht('Signature Verified');
$content = pht('The signature is now verified.');
$continue = pht('Continue to Legalpad Document');
}
}
$dialog = id(new AphrontDialogView())
->setUser($user)
->setTitle($title)
->setMethod('GET')
->addCancelButton($uri, $continue)
->appendChild($content);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Verify Signature'));
return $this->buildApplicationPage(
array(
$crumbs,
$dialog,
),
array(
'title' => pht('Verify Signature'),
));
}
}