Path: blob/master/src/applications/legalpad/controller/LegalpadDocumentSignatureVerificationController.php
13459 views
<?php12final class LegalpadDocumentSignatureVerificationController3extends LegalpadController {45public function shouldAllowPublic() {6return true;7}89public function handleRequest(AphrontRequest $request) {10$viewer = $request->getViewer();11$code = $request->getURIData('code');1213// NOTE: We're using the omnipotent user to handle logged-out signatures14// and corporate signatures.15$signature = id(new LegalpadDocumentSignatureQuery())16->setViewer(PhabricatorUser::getOmnipotentUser())17->withSecretKeys(array($code))18->executeOne();1920if (!$signature) {21return $this->newDialog()22->setTitle(pht('Unable to Verify Signature'))23->appendParagraph(24pht(25'The signature verification code is incorrect, or the signature '.26'has been invalidated. Make sure you followed the link in the '.27'email correctly.'))28->addCancelButton('/', pht('Rats!'));29}3031if ($signature->isVerified()) {32return $this->newDialog()33->setTitle(pht('Signature Already Verified'))34->appendParagraph(pht('This signature has already been verified.'))35->addCancelButton('/', pht('Okay'));36}3738if ($request->isFormPost()) {39$signature40->setVerified(LegalpadDocumentSignature::VERIFIED)41->save();4243return $this->newDialog()44->setTitle(pht('Signature Verified'))45->appendParagraph(pht('The signature is now verified.'))46->addCancelButton('/', pht('Okay'));47}4849$document_link = phutil_tag(50'a',51array(52'href' => '/'.$signature->getDocument()->getMonogram(),53'target' => '_blank',54),55$signature->getDocument()->getTitle());5657$signed_at = phabricator_datetime($signature->getDateCreated(), $viewer);5859$name = $signature->getSignerName();60$email = $signature->getSignerEmail();6162$form = id(new AphrontFormView())63->setUser($viewer)64->appendRemarkupInstructions(65pht('Please verify this document signature.'))66->appendChild(67id(new AphrontFormMarkupControl())68->setLabel(pht('Document'))69->setValue($document_link))70->appendChild(71id(new AphrontFormMarkupControl())72->setLabel(pht('Signed At'))73->setValue($signed_at))74->appendChild(75id(new AphrontFormMarkupControl())76->setLabel(pht('Name'))77->setValue($name))78->appendChild(79id(new AphrontFormMarkupControl())80->setLabel(pht('Email'))81->setValue($email));8283return $this->newDialog()84->setTitle(pht('Verify Signature?'))85->appendChild($form->buildLayoutView())86->addCancelButton('/')87->addSubmitButton(pht('Verify Signature'));88}8990}919293