Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/legalpad/controller/LegalpadDocumentSignatureVerificationController.php
13459 views
1
<?php
2
3
final class LegalpadDocumentSignatureVerificationController
4
extends LegalpadController {
5
6
public function shouldAllowPublic() {
7
return true;
8
}
9
10
public function handleRequest(AphrontRequest $request) {
11
$viewer = $request->getViewer();
12
$code = $request->getURIData('code');
13
14
// NOTE: We're using the omnipotent user to handle logged-out signatures
15
// and corporate signatures.
16
$signature = id(new LegalpadDocumentSignatureQuery())
17
->setViewer(PhabricatorUser::getOmnipotentUser())
18
->withSecretKeys(array($code))
19
->executeOne();
20
21
if (!$signature) {
22
return $this->newDialog()
23
->setTitle(pht('Unable to Verify Signature'))
24
->appendParagraph(
25
pht(
26
'The signature verification code is incorrect, or the signature '.
27
'has been invalidated. Make sure you followed the link in the '.
28
'email correctly.'))
29
->addCancelButton('/', pht('Rats!'));
30
}
31
32
if ($signature->isVerified()) {
33
return $this->newDialog()
34
->setTitle(pht('Signature Already Verified'))
35
->appendParagraph(pht('This signature has already been verified.'))
36
->addCancelButton('/', pht('Okay'));
37
}
38
39
if ($request->isFormPost()) {
40
$signature
41
->setVerified(LegalpadDocumentSignature::VERIFIED)
42
->save();
43
44
return $this->newDialog()
45
->setTitle(pht('Signature Verified'))
46
->appendParagraph(pht('The signature is now verified.'))
47
->addCancelButton('/', pht('Okay'));
48
}
49
50
$document_link = phutil_tag(
51
'a',
52
array(
53
'href' => '/'.$signature->getDocument()->getMonogram(),
54
'target' => '_blank',
55
),
56
$signature->getDocument()->getTitle());
57
58
$signed_at = phabricator_datetime($signature->getDateCreated(), $viewer);
59
60
$name = $signature->getSignerName();
61
$email = $signature->getSignerEmail();
62
63
$form = id(new AphrontFormView())
64
->setUser($viewer)
65
->appendRemarkupInstructions(
66
pht('Please verify this document signature.'))
67
->appendChild(
68
id(new AphrontFormMarkupControl())
69
->setLabel(pht('Document'))
70
->setValue($document_link))
71
->appendChild(
72
id(new AphrontFormMarkupControl())
73
->setLabel(pht('Signed At'))
74
->setValue($signed_at))
75
->appendChild(
76
id(new AphrontFormMarkupControl())
77
->setLabel(pht('Name'))
78
->setValue($name))
79
->appendChild(
80
id(new AphrontFormMarkupControl())
81
->setLabel(pht('Email'))
82
->setValue($email));
83
84
return $this->newDialog()
85
->setTitle(pht('Verify Signature?'))
86
->appendChild($form->buildLayoutView())
87
->addCancelButton('/')
88
->addSubmitButton(pht('Verify Signature'));
89
}
90
91
}
92
93