Ivan - Add new logo, fix user system disabled architecture [skip ci]
This commit is contained in:
parent
3de5196dd5
commit
6bff8e1493
|
@ -179,7 +179,7 @@ class TicketViewer extends React.Component {
|
|||
|
||||
renderTicketEvent(options, index) {
|
||||
return (
|
||||
<TicketEvent {...options} key={index} />
|
||||
<TicketEvent {...options} author={(options.author.length) ? options.author : this.props.ticket.author} key={index} />
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -358,6 +358,7 @@ class TicketViewer extends React.Component {
|
|||
|
||||
export default connect((store) => {
|
||||
return {
|
||||
allowAttachments: store.config['allow-attachments']
|
||||
allowAttachments: store.config['allow-attachments'],
|
||||
userSystemEnabled: store.config['user-system-enabled']
|
||||
};
|
||||
})(TicketViewer);
|
||||
|
|
|
@ -14,6 +14,7 @@ class AdminPanelViewTicket extends React.Component {
|
|||
|
||||
static propTypes = {
|
||||
avoidSeen: React.PropTypes.bool,
|
||||
onRetrieveFail: React.PropTypes.func,
|
||||
assignmentAllowed: React.PropTypes.bool
|
||||
};
|
||||
|
||||
|
@ -108,6 +109,10 @@ class AdminPanelViewTicket extends React.Component {
|
|||
loading: false,
|
||||
ticket: {}
|
||||
});
|
||||
|
||||
if(this.props.onRetrieveFail) {
|
||||
this.props.onRetrieveFail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ class MainCheckTicketPage extends React.Component {
|
|||
});
|
||||
|
||||
API.call({
|
||||
path: '/ticket/get',
|
||||
path: '/ticket/check',
|
||||
data: {
|
||||
captcha: captcha && captcha.getValue(),
|
||||
ticketNumber: form.ticketNumber,
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import React from 'react';
|
||||
import {browserHistory} from 'react-router';
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import AdminPanelViewTicket from 'app/admin/panel/tickets/admin-panel-view-ticket'
|
||||
|
||||
|
@ -10,11 +12,22 @@ class MainViewTicketPage extends React.Component {
|
|||
return (
|
||||
<div className="main-view-ticket-page">
|
||||
<Widget>
|
||||
<AdminPanelViewTicket {...this.props} avoidSeen assignmentAllowed={false} />
|
||||
<AdminPanelViewTicket {...this.props} avoidSeen assignmentAllowed={false} onRetrieveFail={this.onRetrieveFail.bind(this)} />
|
||||
</Widget>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
onRetrieveFail() {
|
||||
if (!this.props.config['user-system-enabled']) {
|
||||
setTimeout(() => {browserHistory.push('/check-ticket')}, 2000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default MainViewTicketPage;
|
||||
|
||||
export default connect((store) => {
|
||||
return {
|
||||
config: store.config
|
||||
};
|
||||
})(MainViewTicketPage);
|
Binary file not shown.
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 5.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 7.6 KiB |
|
@ -63,6 +63,7 @@ class Button extends React.Component {
|
|||
delete props.route;
|
||||
delete props.iconName;
|
||||
delete props.type;
|
||||
delete props.inverted;
|
||||
|
||||
return props;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
.text-editor {
|
||||
|
||||
.text-editor__editor {
|
||||
background-color: white;
|
||||
border: 1px solid $grey;
|
||||
border-radius: 3px;
|
||||
|
||||
|
|
|
@ -275,6 +275,7 @@ export default {
|
|||
'ERROR_URL': 'Invalid URL',
|
||||
'UNVERIFIED_EMAIL': 'Email is not verified yet',
|
||||
'ERROR_UPDATING_SETTINGS': 'An error occurred while trying to update settings',
|
||||
'INVALID_EMAIL_OR_TICKET_NUMBER': 'Invalid email or ticket number',
|
||||
|
||||
//MESSAGES
|
||||
'SIGNUP_SUCCESS': 'You have registered successfully in our support system.',
|
||||
|
|
|
@ -23,7 +23,7 @@ class SessionStore {
|
|||
}
|
||||
|
||||
isLoggedIn() {
|
||||
return !!this.getItem('token');
|
||||
return !!this.getItem('userId');
|
||||
}
|
||||
|
||||
closeSession() {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
include 'ticket/create.php';
|
||||
include 'ticket/comment.php';
|
||||
include 'ticket/get.php';
|
||||
include 'ticket/check.php';
|
||||
include 'ticket/add-custom-response.php';
|
||||
include 'ticket/delete-custom-response.php';
|
||||
include 'ticket/edit-custom-response.php';
|
||||
|
@ -18,6 +19,7 @@ $ticketControllers->setGroupPath('/ticket');
|
|||
$ticketControllers->addController(new CreateController);
|
||||
$ticketControllers->addController(new CommentController);
|
||||
$ticketControllers->addController(new TicketGetController);
|
||||
$ticketControllers->addController(new CheckTicketController);
|
||||
$ticketControllers->addController(new AddCustomResponseController);
|
||||
$ticketControllers->addController(new DeleteCustomResponseController);
|
||||
$ticketControllers->addController(new EditCustomResponseController);
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
use Respect\Validation\Validator as DataValidator;
|
||||
DataValidator::with('CustomValidations', true);
|
||||
|
||||
class CheckTicketController extends Controller {
|
||||
const PATH = '/check';
|
||||
const METHOD = 'POST';
|
||||
|
||||
public function validations() {
|
||||
return [
|
||||
'permission' => 'any',
|
||||
'requestData' => [
|
||||
'ticketNumber' => [
|
||||
'validation' => DataValidator::validTicketNumber(),
|
||||
'error' => ERRORS::INVALID_TICKET
|
||||
],
|
||||
'email' => [
|
||||
'validation' => DataValidator::email(),
|
||||
'error' => ERRORS::INVALID_EMAIL
|
||||
],
|
||||
'captcha' => [
|
||||
'validation' => DataValidator::captcha(),
|
||||
'error' => ERRORS::INVALID_CAPTCHA
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function handler() {
|
||||
if (Controller::isUserSystemEnabled() || Controller::isStaffLogged()) {
|
||||
throw new Exception(ERRORS::NO_PERMISSION);
|
||||
}
|
||||
|
||||
$email = Controller::request('email');
|
||||
$ticket = Ticket::getByTicketNumber(Controller::request('ticketNumber'));
|
||||
|
||||
if($ticket->authorEmail === $email) {
|
||||
$session = Session::getInstance();
|
||||
$session->createTicketSession($ticket->ticketNumber);
|
||||
|
||||
Response::respondSuccess([
|
||||
'token' => $session->getToken(),
|
||||
'ticketNumber' => $ticket->ticketNumber
|
||||
]);
|
||||
} else {
|
||||
throw new Exception(ERRORS::NO_PERMISSION);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,42 +10,49 @@ class CommentController extends Controller {
|
|||
private $content;
|
||||
|
||||
public function validations() {
|
||||
$validations = [
|
||||
'permission' => 'user',
|
||||
'requestData' => [
|
||||
'content' => [
|
||||
'validation' => DataValidator::length(20, 5000),
|
||||
'error' => ERRORS::INVALID_CONTENT
|
||||
],
|
||||
'ticketNumber' => [
|
||||
'validation' => DataValidator::validTicketNumber(),
|
||||
'error' => ERRORS::INVALID_TICKET
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
if(!Controller::isUserSystemEnabled()) {
|
||||
$validations['permission'] = 'any';
|
||||
$session = Session::getInstance();
|
||||
$session = Session::getInstance();
|
||||
|
||||
$validations['requestData']['csrf_token'] = [
|
||||
'validation' => DataValidator::equals($session->getToken()),
|
||||
'error' => ERRORS::NO_PERMISSION
|
||||
if (Controller::isUserSystemEnabled() || Controller::isStaffLogged()) {
|
||||
return [
|
||||
'permission' => 'user',
|
||||
'requestData' => [
|
||||
'content' => [
|
||||
'validation' => DataValidator::length(20, 5000),
|
||||
'error' => ERRORS::INVALID_CONTENT
|
||||
],
|
||||
'ticketNumber' => [
|
||||
'validation' => DataValidator::validTicketNumber(),
|
||||
'error' => ERRORS::INVALID_TICKET
|
||||
]
|
||||
]
|
||||
];
|
||||
$validations['requestData']['ticketNumber'] = [
|
||||
'validation' => DataValidator::equals($session->getTicketNumber()),
|
||||
'error' => ERRORS::INVALID_TICKET
|
||||
} else {
|
||||
return [
|
||||
'permission' => 'any',
|
||||
'requestData' => [
|
||||
'content' => [
|
||||
'validation' => DataValidator::length(20, 5000),
|
||||
'error' => ERRORS::INVALID_CONTENT
|
||||
],
|
||||
'ticketNumber' => [
|
||||
'validation' => DataValidator::equals($session->getTicketNumber()),
|
||||
'error' => ERRORS::INVALID_TICKET
|
||||
],
|
||||
'csrf_token' => [
|
||||
'validation' => DataValidator::equals($session->getToken()),
|
||||
'error' => Controller::request('csrf_token') . ' ' . $session->getToken()
|
||||
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
return $validations;
|
||||
}
|
||||
|
||||
public function handler() {
|
||||
$session = Session::getInstance();
|
||||
$this->requestData();
|
||||
|
||||
if (!Controller::isUserSystemEnabled() || $session->isLoggedWithId($this->ticket->author->id) || Controller::isStaffLogged()) {
|
||||
if ((!Controller::isUserSystemEnabled() && !Controller::isStaffLogged()) || $session->isLoggedWithId(($this->ticket->author) ? $this->ticket->author->id : 0) || (Controller::isStaffLogged() && $session->isLoggedWithId(($this->ticket->owner) ? $this->ticket->owner->id : 0))) {
|
||||
$this->storeComment();
|
||||
|
||||
Log::createLog('COMMENT', $this->ticket->ticketNumber);
|
||||
|
@ -58,13 +65,8 @@ class CommentController extends Controller {
|
|||
|
||||
private function requestData() {
|
||||
$ticketNumber = Controller::request('ticketNumber');
|
||||
$email = Controller::request('email');
|
||||
$this->ticket = Ticket::getByTicketNumber($ticketNumber);
|
||||
$this->content = Controller::request('content', true);
|
||||
|
||||
if(!Controller::isUserSystemEnabled() && $this->ticket->authorEmail !== $email && !Controller::isStaffLogged()) {
|
||||
throw new Exception(ERRORS::NO_PERMISSION);
|
||||
}
|
||||
}
|
||||
|
||||
private function storeComment() {
|
||||
|
@ -84,7 +86,7 @@ class CommentController extends Controller {
|
|||
$this->ticket->unreadStaff = true;
|
||||
$comment->authorUser = Controller::getLoggedUser();
|
||||
}
|
||||
|
||||
|
||||
$this->ticket->addEvent($comment);
|
||||
$this->ticket->store();
|
||||
}
|
||||
|
|
|
@ -9,79 +9,49 @@ class TicketGetController extends Controller {
|
|||
private $ticket;
|
||||
|
||||
public function validations() {
|
||||
$validations = [
|
||||
'permission' => 'user',
|
||||
'requestData' => [
|
||||
'ticketNumber' => [
|
||||
'validation' => DataValidator::validTicketNumber(),
|
||||
'error' => ERRORS::INVALID_TICKET
|
||||
$session = Session::getInstance();
|
||||
|
||||
if (Controller::isUserSystemEnabled() || Controller::isStaffLogged()) {
|
||||
return [
|
||||
'permission' => 'user',
|
||||
'requestData' => [
|
||||
'ticketNumber' => [
|
||||
'validation' => DataValidator::validTicketNumber(),
|
||||
'error' => ERRORS::INVALID_TICKET
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
if(!Controller::isUserSystemEnabled() && !Controller::isStaffLogged()) {
|
||||
$validations['permission'] = 'any';
|
||||
|
||||
if(Controller::request('token')) {
|
||||
$session = Session::getInstance();
|
||||
|
||||
$validations['requestData']['csrf_token'] = [
|
||||
'validation' => DataValidator::equals($session->getToken()),
|
||||
'error' => ERRORS::NO_PERMISSION
|
||||
];
|
||||
$validations['requestData']['ticketNumber'] = [
|
||||
'validation' => DataValidator::equals($session->getTicketNumber()),
|
||||
'error' => ERRORS::INVALID_TICKET
|
||||
];
|
||||
} else {
|
||||
$validations['requestData']['email'] = [
|
||||
'validation' => DataValidator::email(),
|
||||
'error' => ERRORS::INVALID_EMAIL
|
||||
];
|
||||
$validations['requestData']['captcha'] = [
|
||||
'validation' => DataValidator::captcha(),
|
||||
'error' => ERRORS::INVALID_CAPTCHA
|
||||
];
|
||||
}
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'permission' => 'any',
|
||||
'requestData' => [
|
||||
'ticketNumber' => [
|
||||
'validation' => DataValidator::equals($session->getTicketNumber()),
|
||||
'error' => ERRORS::INVALID_TICKET
|
||||
],
|
||||
'csrf_token' => [
|
||||
'validation' => DataValidator::equals($session->getToken()),
|
||||
'error' => $session->getToken() . ' != ' . Controller::request('csrf_token')
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
return $validations;
|
||||
}
|
||||
|
||||
public function handler() {
|
||||
$email = Controller::request('email');
|
||||
|
||||
$this->ticket = Ticket::getByTicketNumber(Controller::request('ticketNumber'));
|
||||
|
||||
if(!Controller::isUserSystemEnabled() && !Controller::isStaffLogged()) {
|
||||
if($this->ticket->authorEmail === $email) {
|
||||
if(!Controller::request('token')) {
|
||||
$this->generateSessionToken();
|
||||
} else {
|
||||
Response::respondSuccess($this->ticket->toArray());
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
if(Controller::isUserSystemEnabled() || Controller::isStaffLogged()) {
|
||||
if ($this->shouldDenyPermission()) {
|
||||
throw new Exception(ERRORS::NO_PERMISSION);
|
||||
} else {
|
||||
Response::respondSuccess($this->ticket->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->shouldDenyPermission()) {
|
||||
throw new Exception(ERRORS::NO_PERMISSION);
|
||||
} else {
|
||||
Response::respondSuccess($this->ticket->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
private function generateSessionToken() {
|
||||
$session = Session::getInstance();
|
||||
$token = Hashing::generateRandomToken();
|
||||
|
||||
$session->createTicketSession($this->ticket->ticketNUmber);
|
||||
|
||||
Response::respondSuccess(['token' => $token, 'ticketNumber' => $this->ticket->ticketNUmber]);
|
||||
}
|
||||
|
||||
private function shouldDenyPermission() {
|
||||
$user = Controller::getLoggedUser();
|
||||
|
||||
|
|
|
@ -81,9 +81,7 @@ class Ticket extends DataStore {
|
|||
'priority' => $this->priority,
|
||||
'author' => $this->authorToArray(),
|
||||
'owner' => $this->ownerToArray(),
|
||||
'events' => $this->eventsToArray(),
|
||||
'authorEmail' => $this->authorEmail,
|
||||
'authorName' => $this->authorName
|
||||
'events' => $this->eventsToArray()
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -97,7 +95,10 @@ class Ticket extends DataStore {
|
|||
'email' => $author->email
|
||||
];
|
||||
} else {
|
||||
return [];
|
||||
return [
|
||||
'name' => $this->authorName,
|
||||
'email' => $this->authorEmail
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue