mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-31 01:35:15 +02:00
[DEV-340] Refactor edit ticket comment no permission validations (#1207)
* Refactor edit ticket comment no permission validations * Refactor edit comment path
This commit is contained in:
parent
713a5b5ee1
commit
0ecf88237f
@ -53,29 +53,17 @@ class EditCommentController extends Controller {
|
||||
$newcontent = Controller::request('content', true);
|
||||
$ticketNumberLog = null;
|
||||
$ticketEvent = Ticketevent::getTicketEvent(Controller::request('ticketEventId'));
|
||||
$commentAuthor = null;
|
||||
|
||||
if(!$ticketEvent->isNull()) {
|
||||
$ticket = Ticket::getDataStore($ticketEvent->ticketId);
|
||||
$commentAuthor = $ticketEvent->toArray()["author"];
|
||||
} else {
|
||||
$ticket = Ticket::getByTicketNumber(Controller::request('ticketNumber'));
|
||||
$commentAuthor = $ticket->toArray()["author"];
|
||||
}
|
||||
|
||||
if (!$ticketEvent->isNull()) {
|
||||
$ticketEventArray = $ticketEvent->toArray();
|
||||
$userArray = $user->toArray();
|
||||
|
||||
if($user->id !== $ticketEventArray["author"]["id"] && $user->id !== $ticket->authorId) {
|
||||
throw new RequestException(ERRORS::NO_PERMISSION);
|
||||
}
|
||||
|
||||
if((!!$userArray["isStaff"] === !!$ticketEventArray["author"]["staff"]) && ($user->id !== $ticketEventArray["author"]["id"])) {
|
||||
throw new RequestException(ERRORS::NO_PERMISSION);
|
||||
}
|
||||
|
||||
if (!!$userArray["isStaff"] !== !!$ticketEventArray["author"]["staff"]) {
|
||||
throw new RequestException(ERRORS::NO_PERMISSION);
|
||||
}
|
||||
} else if ($user->id !== $ticket->authorId) {
|
||||
if((!!$user->toArray()["isStaff"] !== !!$commentAuthor["staff"]) || ($user->id !== $commentAuthor["id"])) {
|
||||
throw new RequestException(ERRORS::NO_PERMISSION);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user