commit - a6db4a20d5b9d856a54376cecd639369f64411f3
commit + 993c0b7bf80797b107f5ca43ccb42f2c012634fb
blob - e0b3b628851baabd27d7ae763adc09852642b035
blob + c20696d45ab25f3bf424bdd66170aec79aa50537
--- module/Securitx/src/Controller/SecuritxController.php
+++ module/Securitx/src/Controller/SecuritxController.php
use Securitx\Form\CompanyForm;
use Securitx\Form\ForgotForm;
use Securitx\Form\SendForm;
+use Securitx\Form\TwofaForm;
use Laminas\Mvc\InjectApplicationEventInterface;
use Laminas\Mvc\Controller\AbstractActionController;
if (!$member || !$member->verified)
return $this->redirect()->toRoute('securitx');
if ((time() - $member->moddate) > 60 * 60 * 24) {
- if ((time() - $member->twofa_moddate) > 60 * 60 * 10 ||
+ if ((time() - $member->twofa_moddate) > 60 * 10 ||
!$member->twofa_moddate) {
$member->twofa = rand(1000000, 9999999);
$member->twofa_moddate = time();
]);
}
}
- public function twofaAction() {
- $member = new Member('member');
- $id = $this->params()->fromRoute('id');
-
- try {
- $member = $this->member_table->getVMember($id);
- } catch (\InvalidArgumentException $ex) {
- return $this->redirect()->toRoute('securitx');
- }
- return new ViewModel([
- 'member' => $member,
- ]);
- }
public function requestadminAction() {
if (!$this->checkAnyAdmin())
return $this->redirect()->toRoute('securitx');
}
}
+ public function twofaAction() {
+ $member = new Member('member');
+ $id = $this->params()->fromRoute('id');
+
+ try {
+ $member = $this->member_table->getVMember($id);
+ } catch (\InvalidArgumentException $ex) {
+ return $this->redirect()->toRoute('securitx');
+ }
+
+ $form = new TwofaForm();
+ if ((time() - $member->twofa_moddate) > 60 * 10)
+ $expired = true;
+ else
+ $expired = false;
+ $request = $this->getRequest();
+ if (!$request->isPost()) {
+ return new ViewModel([
+ 'member' => $member,
+ 'valid' => '',
+ 'expired' => $expired,
+ 'form' => $form,
+ ]);
+ }
+ $form->setData($request->getPost());
+ if (!$form->isValid()) {
+ return new ViewModel([
+ 'member' => $member,
+ 'valid' => '',
+ 'expired' => $expired,
+ 'form' => $form,
+ ]);
+ }
+ $data = $form->getData();
+ if (!$data['code']) {
+ return new ViewModel([
+ 'member' => $member,
+ 'valid' => 'A code is required',
+ 'expired' => $expired,
+ 'form' => $form,
+ ]);
+ }
+ if($data['code'] != $member->twofa) {
+ return new ViewModel([
+ 'member' => $member,
+ 'valid' => 'Incorrect code',
+ 'expired' => $expired,
+ 'form' => $form,
+ ]);
+ } else {
+ $member->moddate = time();
+ $member->twofa = '';
+ $member->twofa_moddate = '';
+ $this->member_table->saveMember($member);
+ return $this->redirect()->toRoute('securitx',
+ array(
+ 'action' => 'home',
+ 'id' => $member->u_key,
+ )
+ );
+ }
+ }
public function requestAction() {
if (!$this->checkAnyAdmin())
return $this->redirect()->toRoute('securitx');
blob - /dev/null
blob + 5e0ff4cfdbcdc7be147ebd81461c79c8d59d48f7 (mode 644)
--- /dev/null
+++ module/Securitx/src/Form/TwofaForm.php
+<?php
+namespace Securitx\Form;
+
+use Laminas\Form\Form;
+use Laminas\Form\Element;
+
+class TwofaForm extends Form {
+ private $site_key, $secret_key;
+ public function __construct() {
+ parent::__construct();
+
+ $this->add([
+ 'name' => 'code',
+ 'type' => 'text',
+ 'options' => [
+ 'label' => 'Verification code',
+ ],
+ ]);
+ $this->add([
+ 'name' => 'submit',
+ 'type' => 'submit',
+ 'attributes' => [
+ 'value' => 'Verify Code',
+ 'id' => 'submitbutton',
+ ],
+ ]);
+ }
+}
blob - 7931b5775fa1ded4b911dba83e096545f8bb214e
blob + ea243b9c8111572072235ebedeb7ab6077303f55
--- module/Securitx/view/securitx/home/home.phtml
+++ module/Securitx/view/securitx/home/home.phtml
if ($has_domain && !$member->r_admin && !$member->r_editor && !$member->is_admin && !$member->is_editor) {
echo "You are an employee of the company. Please request an action below.";
}
- if ($has_domain && !$member->is_admin && !$member->is_editor) {
- echo "Please wait for an administrator to review your request";
+ if ($has_domain && !$member->is_admin && !$member->is_editor && ($member->r_admin || $member->r_editor)) {
+ echo "<br />Please wait for an administrator to review your request";
}
if (!$member->is_admin && !$member->is_editor && !$has_domain) { ?>
<p><a class="btn btn-secondary btn-lg" href="/securitx/upload/<?= $member->u_key ?>">Upload files to <?= $company ?> »</a></p>
blob - 4f61cec26348400ff9ca32726e54cc546119d9f1
blob + 7d998b470d399af9657c04d176ca1e407ff3a603
--- module/Securitx/view/securitx/twofa/twofa.phtml
+++ module/Securitx/view/securitx/twofa/twofa.phtml
<p>Hello, <?= $member->first ?>,<br />Please enter the code that was emailed to you.<br />If you have not received the email, check your Junk folder.</p>
<hr class="my-4">
+<?php
+ $code = $form->get('code');
+ $code->setAttribute('class', 'form-control');
+ $code->setAttribute('placeholder', 'Please enter the code you received');
+
+ $submit = $form->get('submit');
+ $submit->setAttribute('class', 'btn btn-primary');
+
+ $form->setAttribute('action', $this->url('securitx',
+ ['action' => 'twofa', 'id'=> $member->u_key]));
+ $form->prepare();
+
+ echo $this->form()->openTag($form);
+ if (!$expired) {
+?>
+ <div class="form-group">
+ <?= $this->formLabel($code) ?>
+ <?= $this->formElement($code) ?>
+ <?= $this->formElementErrors()->render($code,
+ ['class' => 'help-block']) ?>
+ </div>
+ <p style="color: red"><?= $valid ?></p>
+ <div class="form-group">
+ <?= $this->formSubmit($form->get('submit')) ?>
+ </div>
+ <br /><p><a class="a a-pad" href="/securitx/home/<?= $member->u_key ?>">Go home</a></p>
+<?php
+ } else {
+ echo "Your code has expired. Please <a class=\"a\" href=\"/securitx/home/$member->u_key\">click here</a> to receive a new code.";
+ }
+?>
</div>