Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change message in session logout API #69

Open
wants to merge 3 commits into
base: 1.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions API/Threads.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Webkul\UVDesk\CoreFrameworkBundle\Entity\Ticket;
use Webkul\UVDesk\CoreFrameworkBundle\Entity\TicketStatus;
use Webkul\UVDesk\CoreFrameworkBundle\Entity\User;
use Webkul\UVDesk\CoreFrameworkBundle\Entity\UserInstance;
use Webkul\UVDesk\CoreFrameworkBundle\Entity\Attachment;

use Webkul\UVDesk\CoreFrameworkBundle\Workflow\Events as CoreWorkflowEvents;
Expand Down Expand Up @@ -117,9 +118,17 @@ public function saveThread(Request $request, $ticketid, ContainerInterface $cont
// Create Thread
$thread = $container->get('ticket.service')->createThread($ticket, $threadDetails);

$customer = $this->getDoctrine()->getRepository(UserInstance::class)->findOneBy(array('user' => $user->getId(), 'supportRole' => 4 ));

// Check for thread types
switch ($thread->getThreadType()) {
case 'note':

if ($customer) {
$json['success'] = "success', Can't add note user account.";
return new JsonResponse($json, Response::HTTP_BAD_REQUEST);
}

$event = new CoreWorkflowEvents\Ticket\Note();
$event
->setTicket($ticket)
Expand All @@ -145,6 +154,11 @@ public function saveThread(Request $request, $ticketid, ContainerInterface $cont
break;
case 'forward':
// Prepare headers
if ($customer) {
$json['success'] = "success', Can't forward ticket to user account.";
return new JsonResponse($json, Response::HTTP_BAD_REQUEST);
}

$headers = ['References' => $ticket->getReferenceIds()];

if (null != $ticket->currentThread->getMessageId()) {
Expand Down
18 changes: 18 additions & 0 deletions Security/Guards/APIGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,24 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
'error_code' => self::INVALID_CREDNETIALS,
];

break;
case 'An authentication exception occurred.':
if ($request->attributes->get('_route') == 'uvdesk_api_bundle_sessions_api_v1.0_logout_session'){
$data = [
'status' => false,
'message' => 'This Session token has been already expired successfully.',
'error_code' => self::INVALID_CREDNETIALS,
];

return new JsonResponse($data, Response::HTTP_FORBIDDEN);
}

$data = [
'status' => false,
'message' => 'This api is disabled from admin end, please check once again.',
'error_code' => self::INVALID_CREDNETIALS,
];

break;
default:
$data = [
Expand Down