2014-01-15 02:17:18 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class LegalpadDocumentSignatureVerificationController
|
2014-07-04 17:04:28 +02:00
|
|
|
extends LegalpadController {
|
2014-01-15 02:17:18 +01:00
|
|
|
|
2014-07-04 17:04:28 +02:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
2014-01-15 02:17:18 +01:00
|
|
|
}
|
|
|
|
|
2015-07-30 02:02:10 +02:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$viewer = $request->getViewer();
|
|
|
|
$code = $request->getURIData('code');
|
2014-01-17 20:40:26 +01:00
|
|
|
|
2014-07-04 17:04:28 +02:00
|
|
|
// NOTE: We're using the omnipotent user to handle logged-out signatures
|
|
|
|
// and corporate signatures.
|
2014-01-17 20:40:26 +01:00
|
|
|
$signature = id(new LegalpadDocumentSignatureQuery())
|
2014-07-04 17:04:28 +02:00
|
|
|
->setViewer(PhabricatorUser::getOmnipotentUser())
|
2015-07-30 02:02:10 +02:00
|
|
|
->withSecretKeys(array($code))
|
2014-01-17 20:40:26 +01:00
|
|
|
->executeOne();
|
2014-01-15 02:17:18 +01:00
|
|
|
|
|
|
|
if (!$signature) {
|
2014-07-04 17:04:28 +02:00
|
|
|
return $this->newDialog()
|
|
|
|
->setTitle(pht('Unable to Verify Signature'))
|
|
|
|
->appendParagraph(
|
|
|
|
pht(
|
|
|
|
'The signature verification code is incorrect, or the signature '.
|
|
|
|
'has been invalidated. Make sure you followed the link in the '.
|
|
|
|
'email correctly.'))
|
|
|
|
->addCancelButton('/', pht('Rats!'));
|
2014-01-15 02:17:18 +01:00
|
|
|
}
|
|
|
|
|
2014-07-04 17:04:28 +02:00
|
|
|
if ($signature->isVerified()) {
|
|
|
|
return $this->newDialog()
|
|
|
|
->setTitle(pht('Signature Already Verified'))
|
2015-05-22 09:27:56 +02:00
|
|
|
->appendParagraph(pht('This signature has already been verified.'))
|
2014-07-04 17:04:28 +02:00
|
|
|
->addCancelButton('/', pht('Okay'));
|
|
|
|
}
|
2014-01-15 02:17:18 +01:00
|
|
|
|
2014-07-04 17:04:28 +02:00
|
|
|
if ($request->isFormPost()) {
|
|
|
|
$signature
|
|
|
|
->setVerified(LegalpadDocumentSignature::VERIFIED)
|
|
|
|
->save();
|
2014-01-15 02:17:18 +01:00
|
|
|
|
2014-07-04 17:04:28 +02:00
|
|
|
return $this->newDialog()
|
|
|
|
->setTitle(pht('Signature Verified'))
|
|
|
|
->appendParagraph(pht('The signature is now verified.'))
|
|
|
|
->addCancelButton('/', pht('Okay'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$document_link = phutil_tag(
|
|
|
|
'a',
|
2014-01-15 02:17:18 +01:00
|
|
|
array(
|
2014-07-04 17:04:28 +02:00
|
|
|
'href' => '/'.$signature->getDocument()->getMonogram(),
|
|
|
|
'target' => '_blank',
|
2014-01-15 02:17:18 +01:00
|
|
|
),
|
2014-07-04 17:04:28 +02:00
|
|
|
$signature->getDocument()->getTitle());
|
|
|
|
|
|
|
|
$signed_at = phabricator_datetime($signature->getDateCreated(), $viewer);
|
|
|
|
|
|
|
|
$name = $signature->getSignerName();
|
|
|
|
$email = $signature->getSignerEmail();
|
|
|
|
|
|
|
|
$form = id(new AphrontFormView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->appendRemarkupInstructions(
|
|
|
|
pht('Please verify this document signature.'))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormMarkupControl())
|
|
|
|
->setLabel(pht('Document'))
|
|
|
|
->setValue($document_link))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormMarkupControl())
|
|
|
|
->setLabel(pht('Signed At'))
|
|
|
|
->setValue($signed_at))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormMarkupControl())
|
|
|
|
->setLabel(pht('Name'))
|
|
|
|
->setValue($name))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormMarkupControl())
|
|
|
|
->setLabel(pht('Email'))
|
|
|
|
->setValue($email));
|
|
|
|
|
|
|
|
return $this->newDialog()
|
|
|
|
->setTitle(pht('Verify Signature?'))
|
|
|
|
->appendChild($form->buildLayoutView())
|
|
|
|
->addCancelButton('/')
|
|
|
|
->addSubmitButton(pht('Verify Signature'));
|
2014-01-15 02:17:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|