Got started adding internal usage. A lot more work to handle this than I originally thought
parent
e21c26689a
commit
fddd3de664
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace BusinessLogic\Exceptions;
|
||||
|
||||
|
||||
class InternalUseOnlyException extends ApiFriendlyException {
|
||||
function __construct() {
|
||||
parent::__construct("This endpoint can only be used internally", "Internal Use Only", 400);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: cokoch
|
||||
* Date: 5/2/2017
|
||||
* Time: 12:28 PM
|
||||
*/
|
||||
|
||||
namespace BusinessLogic\Exceptions;
|
||||
|
||||
|
||||
class SessionNotActiveException extends ApiFriendlyException {
|
||||
function __construct() {
|
||||
parent::__construct("You must be logged in to call internal API methods", "Authentication Required", 401);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Controllers;
|
||||
|
||||
|
||||
use BusinessLogic\Exceptions\InternalUseOnlyException;
|
||||
use BusinessLogic\Helpers;
|
||||
|
||||
abstract class InternalApiController {
|
||||
function checkForInternalUseOnly() {
|
||||
$tokenHeader = Helpers::getHeader('X-AUTH-TOKEN');
|
||||
if ($tokenHeader === null || trim($tokenHeader) === '') {
|
||||
throw new InternalUseOnlyException();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Controllers\Tickets;
|
||||
|
||||
|
||||
use BusinessLogic\Tickets\TicketRetriever;
|
||||
use Controllers\InternalApiController;
|
||||
|
||||
class ResendTicketEmailToCustomerController extends InternalApiController {
|
||||
function get($ticketId) {
|
||||
global $applicationContext, $userContext, $hesk_settings;
|
||||
|
||||
$this->checkForInternalUseOnly();
|
||||
|
||||
/* @var $ticketRetriever TicketRetriever */
|
||||
$ticketRetriever = $applicationContext->get[TicketRetriever::class];
|
||||
$ticket = $ticketRetriever->getTicketById($ticketId, $hesk_settings, $userContext);
|
||||
|
||||
$reply = -1;
|
||||
if (isset($_GET['replyId'])) {
|
||||
$reply = $_GET['replyId'];
|
||||
}
|
||||
|
||||
//-- TODO Get reply if necessary including all attachments :O
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue