commit - 993c0b7bf80797b107f5ca43ccb42f2c012634fb
commit + 1ad0345441c7eb0baf4b7880f62449b4c794f325
blob - 0a362d8c5283516f5ec5988da73b282c86e0e768
blob + f0a7a31c4f00823625bb0dd9bea18d74851fbf7e
--- module/Securitx/config/module.config.php
+++ module/Securitx/config/module.config.php
'securitx/securitx/user' => __DIR__ . '/../view/securitx/user/user.phtml',
'securitx/securitx/twofa' => __DIR__ . '/../view/securitx/twofa/twofa.phtml',
'securitx/securitx/forgot' => __DIR__ . '/../view/securitx/forgot/forgot.phtml',
- 'securitx/securitx/requestadmin' => __DIR__ . '/../view/securitx/requestadmin/requestadmin.phtml',
- 'securitx/securitx/requesteditor' => __DIR__ . '/../view/securitx/requesteditor/requesteditor.phtml',
],
'template_path_stack' => [
__DIR__ . '/../view/securitx',
blob - c20696d45ab25f3bf424bdd66170aec79aa50537
blob + 5a9ecf0169ef60623e147cd113fb959cdb63b511
--- module/Securitx/src/Controller/SecuritxController.php
+++ module/Securitx/src/Controller/SecuritxController.php
}
return 0;
}
+ public function authempAction() {
+ if (!$this->checkAnyAdmin())
+ return $this->redirect()->toRoute('securitx');
+ $admin = $this->getMember();
+ if (!$admin->is_admin)
+ goto ret;
+ if ($_GET) {
+ if (array_key_exists('member', $_GET))
+ $member = $this->member_table->getVMember(
+ $_GET['member']);
+ else
+ goto ret;
+ if (!$member)
+ goto ret;
+ if (array_key_exists('type', $_GET))
+ $type = $_GET['type'];
+ else
+ goto ret;
+ if (array_key_exists('action', $_GET))
+ $action = $_GET['action'];
+ else
+ goto ret;
+ if ($action == "allow") {
+ if ($type == "admin")
+ $member->is_admin = 1;
+ else
+ $member->is_editor = 1;
+ } else {
+ if ($type == "admin")
+ $member->is_admin = 2;
+ else
+ $member->is_editor = 2;
+ }
+ $company =
+ $this->company_table->getCompany($member->company_id);
+ $member->r_admin = 0;
+ $member->r_editor = 0;
+ $this->member_table->saveMember($member);
+
+ $emailer = new Emailer($this->email_host);
+ $emailer->sendAuthEmail($member->email, $member->first,
+ $member->last, $action, $type,
+ $company->name, $this->hipaa['notice']);
+ }
+ret:
+ return $this->redirect()->toRoute('securitx',
+ array(
+ 'action' => 'home',
+ 'id' => $admin->u_key,
+ )
+ );
+ }
public function companiesAction() {
if (!$this->checkAnyAdmin())
return $this->redirect()->toRoute('securitx');
if (!$member || !$member->verified)
return $this->redirect()->toRoute('securitx');
- $this->member_table->saveMember($member);
-
/* check member domain */
$company =
$this->company_table->getCompany($member->company_id);
else
$has_domain = 0;
+ if ($_GET && $has_domain) {
+ $admins = $this->member_table->getAllAdmins();
+ if (array_key_exists('r_admin', $_GET)) {
+ $type = "admin";
+ if ($member->is_admin > 0)
+ goto skip;
+ $member->r_admin = 1;
+ }
+ if (array_key_exists('r_editor', $_GET)) {
+ $type = "editor";
+ if ($member->is_editor > 0)
+ goto skip;
+ $member->r_editor = 1;
+ }
+ $emailer = new Emailer($this->email_host);
+ foreach ($admins as $admin) {
+ $url1 = $this->url()->fromRoute(
+ 'securitx',
+ [
+ 'action' => 'authemp',
+ 'id' => $admin->u_key,
+ ],
+ [
+ 'query' => [
+ 'member' => $member->u_key,
+ 'type' => $type,
+ 'action' => 'allow',
+ ],
+ ],
+ [
+ 'force_canonical' => true,
+ ]
+ );
+ $url2 = $this->url()->fromRoute(
+ 'securitx',
+ [
+ 'action' => 'authemp',
+ 'id' => $admin->u_key,
+ ],
+ [
+ 'query' => [
+ 'member' => $member->u_key,
+ 'type' => $type,
+ 'action' => 'deny',
+ ],
+ ],
+ [
+ 'force_canonical' => true,
+ ]
+ );
+ $url1 = "https://" . $_SERVER['SERVER_NAME'] .
+ $url1;
+ $url2 = "https://" . $_SERVER['SERVER_NAME'] .
+ $url2;
+ $emailer->sendAdminRequest($admin, $member,
+ $url1, $url2, $this->hipaa['notice'],
+ $type);
+ }
+ }
+skip:
+ $this->member_table->saveMember($member);
+
$inviter = "";
if ($member->inviter) {
$admin =
'id' => $member->v_key,
],
[
- 'force_canonical' => true,
+ 'force_canonical' => true,
]
);
$emailer = new Emailer($this->email_host);
blob - be9bdf845ec75c46dc4d5bcbd1e2de821539f255
blob + a727cf3dd102e4a87b3056ddcf578521adb0cfe0
--- module/Securitx/src/Model/Emailer.php
+++ module/Securitx/src/Model/Emailer.php
$this->ip = $email_host['ip'];
}
+ public function sendAuthEmail($email, $first, $last, $action, $type,
+ $company, $hipaa) {
+ if ($action == "allow")
+ $auth = "authorized";
+ else
+ $auth = "denied";
+ if ($type == "admin")
+ $thetype = "administrator";
+ else
+ $thetype = "editor";
+
+ $message = new Message();
+ $message->addFrom('no-reply@' . $this->hostname, 'SecuritX');
+ $message->addTo("$email", "$first $last");
+ $message->addReplyTo('no-reply@' . $this->hostname, 'SecuritX');
+ $message->setSubject('Your SecuritX Employee Request');
+ $message->setBody(
+ "Hello $first,\r\n\r\nAn administrator has $auth your " .
+ "request to become an $thetype of $company. Please see ".
+ "your administrator for more details. Thanks!" .
+ "\r\n\r\n--\r\n\r\n$hipaa"
+ );
+
+ $transport = new SmtpTransport();
+ $options = new SmtpOptions([
+ 'name' => $this->hostname,
+ 'host' => $this->ip,
+ ]);
+ $transport->setOptions($options);
+ $transport->send($message);
+ }
+ public function sendAdminRequest($admin, $member, $url1, $url2, $hipaa,
+ $type) {
+ $message = new Message();
+ $message->addFrom('no-reply@' . $this->hostname, 'SecuritX');
+ $message->addTo("$admin->email", "$admin->first $admin->last");
+ $message->addReplyTo('no-reply@' . $this->hostname, 'SecuritX');
+ $message->setSubject('SecuritX Employee Request');
+ $message->setBody(
+ "Hello $admin->first,\r\n\r\n$member->first " .
+ "$member->last has requested $type rights.\r\n" .
+ "\r\nApprove\r\n$url1\r\n\r\n" .
+ "\r\nDeny\r\n$url2\r\n\r\n" .
+ "--\r\n\r\n$hipaa"
+ );
+
+ $transport = new SmtpTransport();
+ $options = new SmtpOptions([
+ 'name' => $this->hostname,
+ 'host' => $this->ip,
+ ]);
+ $transport->setOptions($options);
+ $transport->send($message);
+ }
public function sendTwofa($email, $first, $last, $url, $hipaa, $code) {
$message = new Message();
$message->addFrom('no-reply@' . $this->hostname, 'SecuritX');
blob - f48aee4c1adf8f2c1fe9ff39873d73a1bc68426b
blob + 47270ede993e8f42563fe2adb83515f13eb86229
--- module/Securitx/src/Model/MemberTable.php
+++ module/Securitx/src/Model/MemberTable.php
$row = $rowset->current();
return $row;
}
+ public function getAllAdmins() {
+ return $this->tableGateway->select(['is_admin' => 1]);
+ }
public function getAnyAdmin() {
$rowset = $this->tableGateway->select([
'is_admin' => 1,
blob - ea243b9c8111572072235ebedeb7ab6077303f55
blob + 92918a116b45c2139e8828cd33136d294a6886f6
--- module/Securitx/view/securitx/home/home.phtml
+++ module/Securitx/view/securitx/home/home.phtml
<p>SecuritX home of <?= $member->first ?> <?= $member->last ?></p>
<hr class="my-4">
-<?php if ($member->is_admin) { ?>
+<?php if ($member->is_admin == 1) { ?>
<p><a class="btn btn-secondary btn-lg" href="/securitx/companies/<?= $member->u_key ?>">Edit companies »</a></p>
<?php } ?>
-<?php if ($member->is_admin || $member->is_editor) { ?>
+<?php if ($member->is_admin == 1 || $member->is_editor == 1) { ?>
<p><a class="btn btn-secondary btn-lg" href="/securitx/invite/<?= $member->u_key ?>">Invite a member »</a></p>
<?php }
- if ($member->is_admin || $member->is_editor) { ?>
+ if ($member->is_admin == 1 || $member->is_editor == 1) { ?>
<p><a class="btn btn-secondary btn-lg" href="/securitx/send/<?= $member->u_key ?>">Send files to a member »</a></p>
<?php
if ($c_downloads) { ?>
if ($member->inviter) { ?>
<p><a class="btn btn-secondary btn-lg" href="/securitx/send/<?= $member->u_key ?>">Send files to <?= $inviter ?> »</a></p>
<?php }
- if ($has_domain && !$member->r_admin && !$member->r_editor && !$member->is_admin && !$member->is_editor) {
+ if ($has_domain && !$member->r_admin && !$member->r_editor && $member->is_admin == 0 && $member->is_editor == 0) {
echo "You are an employee of the company. Please request an action below.";
}
- if ($has_domain && !$member->is_admin && !$member->is_editor && ($member->r_admin || $member->r_editor)) {
+ if ($has_domain && $member->is_admin == 0 && $member->is_editor == 0 && ($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) { ?>
+ if ($member->is_admin == 0 && $member->is_editor == 0 && !$has_domain) { ?>
<p><a class="btn btn-secondary btn-lg" href="/securitx/upload/<?= $member->u_key ?>">Upload files to <?= $company ?> »</a></p>
<?php } ?>
<hr class="my-4">
<p>
<?php
- if ($has_domain && !$member->is_admin) {
- if ($member->r_admin && !$member->is_admin) {
+ if ($has_domain && $member->is_admin == 0) {
+ if ($member->r_admin && $member->is_admin == 0) {
echo "<span class='a a-pad'>Administrator rights have been requested</span>";
} else if (!$member->r_admin && !$member->is_admin) {
?>
- <a class="a a-pad" href="/securitx/requestadmin/<?= $member->u_key ?>">Request administration rights</a>
+ <a class="a a-pad" href="/securitx/home/<?= $member->u_key ?>?r_admin=1">Request administrator rights</a>
<?php
- if (!$member->r_editor && !$member->r_admin) {
+ if (!$member->r_editor && !$member->r_admin && $member->is_editor != 2) {
?>
- | <a class="a a-pad" href="/securitx/requesteditor/<?= $member->u_key ?>">Request editor rights</a>
+ | <a class="a a-pad" href="/securitx/home/<?= $member->u_key ?>?r_editor=1">Request editor rights</a>
<?php
- } else if ($member->r_editor && !$member->is_editor && !$member->is_admin) {
+ } else if ($member->r_editor && $member->is_editor == 0 && $member->is_admin == 0) {
echo "|<span class='a a-pad'>Editor rights have been requested</span>";
}
}
blob - 8c29d19e0f28e6516ec9c70ead6223a9ed7d063f (mode 644)
blob + /dev/null
--- module/Securitx/view/securitx/requestadmin/requestadmin.phtml
+++ /dev/null
-<?php
- $this->headTitle('SecuritX: Request Administration Right');
-?>
-<div class="jumbotron">
- <h1 class="display-4">Welcome to SecuritX</h1>
-
- <p>Congratulations! You've reached your SecuritX admin reqester!</p>
-
- <hr class="my-4">
-</div>
blob - 13c0b0ec02405d68cb4f6fc0e71a74d623b5fd36 (mode 644)
blob + /dev/null
--- module/Securitx/view/securitx/requesteditor/requesteditor.phtml
+++ /dev/null
-<?php
- $this->headTitle('SecuritX: Request Editor Right');
-?>
-<div class="jumbotron">
- <h1 class="display-4">Welcome to SecuritX</h1>
-
- <p>Congratulations! You've reached your SecuritX editor reqester!</p>
-
- <hr class="my-4">
-</div>