From 7e1749dbd1afde8f6979fefadb6ecf627aada1be Mon Sep 17 00:00:00 2001 From: Ivan Diaz Date: Sat, 16 Nov 2019 16:07:02 -0300 Subject: [PATCH 01/11] Add create ticket APIKey --- server/controllers/system/add-api-key.php | 10 +++++++++- server/controllers/ticket/create.php | 2 +- server/controllers/user/signup.php | 6 +++++- server/data/ERRORS.php | 5 +++++ server/libs/validations/captcha.php | 12 +++++++++++- server/models/APIKey.php | 15 +++++++++++++-- 6 files changed, 44 insertions(+), 6 deletions(-) diff --git a/server/controllers/system/add-api-key.php b/server/controllers/system/add-api-key.php index 38ef0861..5f922817 100755 --- a/server/controllers/system/add-api-key.php +++ b/server/controllers/system/add-api-key.php @@ -14,10 +14,12 @@ use Respect\Validation\Validator as DataValidator; * @apiPermission staff3 * * @apiParam {String} name Name of the new APIKey. + * @apiParam {String} type Type of APIKey: "REGSITRATION" or "TICKET_CREATE" * * @apiUse NO_PERMISSION * @apiUse INVALID_NAME * @apiUse NAME_ALREADY_USED + * @apiUse INVALID_API_KEY_TYPE * * @apiSuccess {String} data Token of the APIKey. * @@ -34,6 +36,10 @@ class AddAPIKeyController extends Controller { 'name' => [ 'validation' => DataValidator::length(2, 55)->alnum(), 'error' => ERRORS::INVALID_NAME + ], + 'type' => [ + 'validation' => DataValidator::in(APIKey::TYPES), + 'error' => ERRORS::INVALID_API_KEY_TYPE ] ] ]; @@ -43,6 +49,7 @@ class AddAPIKeyController extends Controller { $apiInstance = new APIKey(); $name = Controller::request('name'); + $type = Controller::request('type'); $keyInstance = APIKey::getDataStore($name, 'name'); @@ -51,7 +58,8 @@ class AddAPIKeyController extends Controller { $apiInstance->setProperties([ 'name' => $name, - 'token' => $token + 'token' => $token, + 'type' => $type, ]); $apiInstance->store(); diff --git a/server/controllers/ticket/create.php b/server/controllers/ticket/create.php index 432b6d08..e3059498 100755 --- a/server/controllers/ticket/create.php +++ b/server/controllers/ticket/create.php @@ -75,7 +75,7 @@ class CreateController extends Controller { if(!Controller::isUserSystemEnabled() && !Controller::isStaffLogged()) { $validations['permission'] = 'any'; $validations['requestData']['captcha'] = [ - 'validation' => DataValidator::captcha(), + 'validation' => DataValidator::captcha(APIKey::TICKET_CREATE), 'error' => ERRORS::INVALID_CAPTCHA ]; $validations['requestData']['email'] = [ diff --git a/server/controllers/user/signup.php b/server/controllers/user/signup.php index 8ae934ab..0bc8ec5a 100755 --- a/server/controllers/user/signup.php +++ b/server/controllers/user/signup.php @@ -72,7 +72,7 @@ class SignUpController extends Controller { if(!$this->csvImported) { $validations['requestData']['captcha'] = [ - 'validation' => DataValidator::captcha(), + 'validation' => DataValidator::captcha(APIKey::REGISTRATION), 'error' => ERRORS::INVALID_CAPTCHA ]; } @@ -103,6 +103,10 @@ class SignUpController extends Controller { throw new RequestException(ERRORS::NO_PERMISSION); } + if(!$apiKey->isNull() && $apiKey->type !== APIKey::REGISTRATION) { + throw new RequestException(ERRORS::INVALID_API_KEY_TYPE); + } + $userId = $this->createNewUserAndRetrieveId(); if(MailSender::getInstance()->isConnected()) { diff --git a/server/data/ERRORS.php b/server/data/ERRORS.php index 831086a9..9406ce80 100755 --- a/server/data/ERRORS.php +++ b/server/data/ERRORS.php @@ -251,6 +251,10 @@ * @apiDefine INVALID_COLOR * @apiError {String} INVALID_COLOR The color should be in hexadecimal, preceded by a '#' */ +/** + * @apiDefine INVALID_API_KEY_TYPE + * @apiError {String} INVALID_API_KEY_TYPE Api key type is not one of the availables + */ class ERRORS { const INVALID_CREDENTIALS = 'INVALID_CREDENTIALS'; @@ -317,4 +321,5 @@ class ERRORS { const INVALID_CUSTOM_FIELD_OPTION = 'INVALID_CUSTOM_FIELD_OPTION'; const UNAVAILABLE_STATS = 'UNAVAILABLE_STATS'; const INVALID_COLOR = 'INVALID_COLOR'; + const INVALID_API_KEY_TYPE = 'INVALID_API_KEY_TYPE'; } diff --git a/server/libs/validations/captcha.php b/server/libs/validations/captcha.php index 7ac805c2..e37ca9fa 100755 --- a/server/libs/validations/captcha.php +++ b/server/libs/validations/captcha.php @@ -5,12 +5,22 @@ namespace CustomValidations; use Respect\Validation\Rules\AbstractRule; class Captcha extends AbstractRule { + private $dataStoreName; + + public function __construct($apiKeyType = '') { + if (in_array($apiKeyType, \APIKey::TYPES)) { + $this->apiKeyType = $apiKeyType; + } else if($apiKeyType) { + throw new \Exception(\ERRORS::INVALID_API_KEY_TYPE); + } + } public function validate($reCaptchaResponse) { $reCaptchaPrivateKey = \Setting::getSetting('recaptcha-private')->getValue(); $apiKey = \APIKey::getDataStore(\Controller::request('apiKey'), 'token'); - if (!$reCaptchaPrivateKey || !$apiKey->isNull()) return true; + if (!$reCaptchaPrivateKey) return true; + if (!$apiKey->isNull() && $apiKey->type === $apiKeyType) return true; $reCaptcha = new \ReCaptcha\ReCaptcha($reCaptchaPrivateKey); $reCaptchaValidation = $reCaptcha->verify($reCaptchaResponse, $_SERVER['REMOTE_ADDR']); diff --git a/server/models/APIKey.php b/server/models/APIKey.php index 436b2b14..9cb1c4ff 100755 --- a/server/models/APIKey.php +++ b/server/models/APIKey.php @@ -9,18 +9,29 @@ class APIKey extends DataStore { const TABLE = 'apikey'; + const REGISTRATION = 'REGISTRATION'; + const TICKET_CREATE = 'TICKET_CREATE'; + const TYPES = [APIKey::REGISTRATION, APIKey::TICKET_CREATE]; public static function getProps() { return [ 'name', - 'token' + 'token', + 'type' + ]; + } + + public function getDefaultProps() { + return [ + 'type' => APIKey::REGISTRATION ]; } public function toArray() { return [ 'name' => $this->name, - 'token' => $this->token + 'token' => $this->token, + 'type' => $this->type ]; } } \ No newline at end of file From 01a0435f57e1f723e51a18efc9de5eee6c9ccfa4 Mon Sep 17 00:00:00 2001 From: Ivan Diaz Date: Sat, 16 Nov 2019 17:16:53 -0300 Subject: [PATCH 02/11] Add test for APIKeys --- tests/init.rb | 4 +- tests/scripts.rb | 5 ++- tests/system/add-api-key.rb | 58 +++++++++++++++++----------- tests/system/disable-registration.rb | 17 ++++++-- tests/system/disable-user-system.rb | 19 ++++++++- tests/system/get-api-keys.rb | 41 ++++++++++---------- 6 files changed, 92 insertions(+), 52 deletions(-) diff --git a/tests/init.rb b/tests/init.rb index 5f3ef8a0..773866a6 100644 --- a/tests/init.rb +++ b/tests/init.rb @@ -56,11 +56,11 @@ require './system/edit-department.rb' require './system/delete-department.rb' require './staff/last-events.rb' # require './system/mail-templates.rb' -require './system/disable-registration.rb' -require './system/enable-registration.rb' require './system/add-api-key.rb' require './system/delete-api-key.rb' require './system/get-api-keys.rb' +require './system/disable-registration.rb' +require './system/enable-registration.rb' require './system/file-upload-download.rb' require './system/csv-import.rb' require './ticket/create-tag.rb' diff --git a/tests/scripts.rb b/tests/scripts.rb index 7c1e7bf0..c2020d7d 100644 --- a/tests/scripts.rb +++ b/tests/scripts.rb @@ -89,11 +89,12 @@ class Scripts result['data'] end - def self.createAPIKey(name) + def self.createAPIKey(name, type) request('/system/add-api-key', { csrf_userid: $csrf_userid, csrf_token: $csrf_token, - name: name + name: name, + type: type }) end diff --git a/tests/system/add-api-key.rb b/tests/system/add-api-key.rb index cf8c86d5..ecf2f431 100644 --- a/tests/system/add-api-key.rb +++ b/tests/system/add-api-key.rb @@ -1,30 +1,44 @@ describe'system/add-api-key' do - request('/user/logout') - Scripts.login($staff[:email], $staff[:password], true) + request('/user/logout') + Scripts.login($staff[:email], $staff[:password], true) - it 'should add API key' do - result= request('/system/add-api-key', { - csrf_userid: $csrf_userid, - csrf_token: $csrf_token, - name: 'new API' - }) + it 'should add API key' do + result= request('/system/add-api-key', { + csrf_userid: $csrf_userid, + csrf_token: $csrf_token, + name: 'new API', + type: 'REGISTRATION' + }) - (result['status']).should.equal('success') + (result['status']).should.equal('success') - row = $database.getRow('apikey', 1, 'id') + row = $database.getRow('apikey', 1, 'id') - (row['name']).should.equal('new API') - (result['data']).should.equal(row['token']) + (row['name']).should.equal('new API') + (result['data']).should.equal(row['token']) + end - end - it 'should not add API key' do - result= request('/system/add-api-key', { - csrf_userid: $csrf_userid, - csrf_token: $csrf_token, - name: 'new API' - }) + it 'should not add API key if name already used' do + result= request('/system/add-api-key', { + csrf_userid: $csrf_userid, + csrf_token: $csrf_token, + name: 'new API', + type: 'REGISTRATION' + }) - (result['status']).should.equal('fail') - (result['message']).should.equal('NAME_ALREADY_USED') - end + (result['status']).should.equal('fail') + (result['message']).should.equal('NAME_ALREADY_USED') + end + + it 'should not add API key if invalid type is used' do + result= request('/system/add-api-key', { + csrf_userid: $csrf_userid, + csrf_token: $csrf_token, + name: 'new API2', + type: 'REGISTRATON' + }) + + (result['status']).should.equal('fail') + (result['message']).should.equal('INVALID_API_KEY_TYPE') + end end diff --git a/tests/system/disable-registration.rb b/tests/system/disable-registration.rb index 13e4c06c..539a29dc 100644 --- a/tests/system/disable-registration.rb +++ b/tests/system/disable-registration.rb @@ -1,6 +1,7 @@ describe'/system/disable-registration' do request('/user/logout') Scripts.login($staff[:email], $staff[:password], true) + api_key = Scripts.createAPIKey('registrationKey', 'REGISTRATION')['data'] it 'should not disable registration if password is not correct' do result= request('/system/disable-registration', { @@ -17,7 +18,7 @@ describe'/system/disable-registration' do end it 'should disable registration' do - result= request('/system/disable-registration', { + result = request('/system/disable-registration', { csrf_userid: $csrf_userid, csrf_token: $csrf_token, password: $staff[:password] @@ -31,13 +32,23 @@ describe'/system/disable-registration' do end it 'should not create user in database if registration is false' do - response = request('/user/signup', { + result = request('/user/signup', { :name => 'ponzio', :email => 'jc@ponziolandia.com', :password => 'tequila' }) - (response['status']).should.equal('fail') + (result['status']).should.equal('fail') + (result['message']).should.equal('NO_PERMISSION') + end + it 'should create user if using api key' do + result = request('/user/signup', { + :name => 'ponzio', + :email => 'jc@ponziolandia.com', + :password => 'tequila', + :apiKey => api_key + }) + (result['status']).should.equal('success') end end diff --git a/tests/system/disable-user-system.rb b/tests/system/disable-user-system.rb index 11a6c33d..fa2185bb 100644 --- a/tests/system/disable-user-system.rb +++ b/tests/system/disable-user-system.rb @@ -17,7 +17,7 @@ describe'system/disable-user-system' do row = $database.getRow('user', 1, 'id') (row).should.equal(nil) - numberOftickets= $database.query("SELECT * FROM ticket WHERE author_id IS NULL AND author_email IS NOT NULL AND author_name IS NOT NULL") + numberOftickets = $database.query("SELECT * FROM ticket WHERE author_id IS NULL AND author_email IS NOT NULL AND author_name IS NOT NULL") (numberOftickets.num_rows).should.equal(51) @@ -99,6 +99,21 @@ describe'system/disable-user-system' do (ticket['author_staff_id']).should.equal('1') end + it 'should be able to create a ticket using api' do + api_key = Scripts.createAPIKey('ticketCreateKey', 'TICKET_CREATE')['data'] + request('/user/logout') + result = request('/ticket/create', { + email: 'fromapi@testemail.com', + name: 'Random user', + title: 'created by api', + content: 'this ticket was created using anapi key while user system is disabled', + departmentId: 1, + language: 'en', + apiKey: api_key + }) + (result['status']).should.equal('success') + end + it 'should not disable the user system if it is already disabled 'do request('/user/logout') Scripts.login($staff[:email], $staff[:password], true) @@ -127,7 +142,7 @@ describe'system/disable-user-system' do numberOftickets= $database.query("SELECT * FROM ticket WHERE author_email IS NULL AND author_name IS NULL AND author_id IS NOT NULL" ) - (numberOftickets.num_rows).should.equal(52) + (numberOftickets.num_rows).should.equal(53) end diff --git a/tests/system/get-api-keys.rb b/tests/system/get-api-keys.rb index 518dc818..e6c62900 100644 --- a/tests/system/get-api-keys.rb +++ b/tests/system/get-api-keys.rb @@ -1,26 +1,25 @@ describe'system/get-api-keys' do - request('/user/logout') - Scripts.login($staff[:email], $staff[:password], true) + request('/user/logout') + Scripts.login($staff[:email], $staff[:password], true) - it 'should get all API keys' do - Scripts.createAPIKey('namekey1') - Scripts.createAPIKey('namekey2') - Scripts.createAPIKey('namekey3') - Scripts.createAPIKey('namekey4') - Scripts.createAPIKey('namekey5') - - result = request('/system/get-api-keys', { - csrf_userid: $csrf_userid, - csrf_token: $csrf_token, - }) + it 'should get all API keys' do + Scripts.createAPIKey('namekey1', 'REGISTRATION') + Scripts.createAPIKey('namekey2', 'REGISTRATION') + Scripts.createAPIKey('namekey3', 'REGISTRATION') + Scripts.createAPIKey('namekey4', 'REGISTRATION') + Scripts.createAPIKey('namekey5', 'REGISTRATION') + + result = request('/system/get-api-keys', { + csrf_userid: $csrf_userid, + csrf_token: $csrf_token, + }) - (result['status']).should.equal('success') - (result['data'][0]['name']).should.equal('namekey1') - (result['data'][1]['name']).should.equal('namekey2') - (result['data'][2]['name']).should.equal('namekey3') - (result['data'][3]['name']).should.equal('namekey4') - (result['data'][4]['name']).should.equal('namekey5') - - end + (result['status']).should.equal('success') + (result['data'][0]['name']).should.equal('namekey1') + (result['data'][1]['name']).should.equal('namekey2') + (result['data'][2]['name']).should.equal('namekey3') + (result['data'][3]['name']).should.equal('namekey4') + (result['data'][4]['name']).should.equal('namekey5') + end end From e8dab6922b4a98f1cd2deaff6dc1d2d36bb81e46 Mon Sep 17 00:00:00 2001 From: Ivan Diaz Date: Sat, 16 Nov 2019 17:21:38 -0300 Subject: [PATCH 03/11] Fix frontend to only use registration api keys --- .../app/admin/panel/settings/admin-panel-advanced-settings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/app/admin/panel/settings/admin-panel-advanced-settings.js b/client/src/app/admin/panel/settings/admin-panel-advanced-settings.js index 39f769e0..0855e6e7 100644 --- a/client/src/app/admin/panel/settings/admin-panel-advanced-settings.js +++ b/client/src/app/admin/panel/settings/admin-panel-advanced-settings.js @@ -153,7 +153,7 @@ class AdminPanelAdvancedSettings extends React.Component { ModalContainer.closeModal(); API.call({ path: '/system/add-api-key', - data: {name} + data: {name, type: 'REGISTRATION'} }).then(this.getAllKeys.bind(this)); } @@ -177,7 +177,7 @@ class AdminPanelAdvancedSettings extends React.Component { onRetrieveSuccess(result) { this.setState({ - APIKeys: result.data, + APIKeys: result.data.filter(key => key['type'] === 'REGISTRATION'), selectedAPIKey: -1 }); } From 843bd13281c3cea242516eb25d48ed8284acf199 Mon Sep 17 00:00:00 2001 From: LautaroCesso <59095036+LautaroCesso@users.noreply.github.com> Date: Fri, 20 Dec 2019 16:49:43 -0300 Subject: [PATCH 04/11] Allows space in custom fields name (issue #598) (#681) * replace spaces for underscores in edit custom fields * Create function getCustomFieldParamName --- .../dashboard-edit-profile-page.js | 31 ++++++++++++------- client/src/data/languages/en.js | 4 +-- client/src/lib-core/APIUtils.js | 4 +++ server/libs/Controller.php | 4 +-- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/client/src/app/main/dashboard/dashboard-edit-profile/dashboard-edit-profile-page.js b/client/src/app/main/dashboard/dashboard-edit-profile/dashboard-edit-profile-page.js index 6bf28bfb..75fbd39b 100644 --- a/client/src/app/main/dashboard/dashboard-edit-profile/dashboard-edit-profile-page.js +++ b/client/src/app/main/dashboard/dashboard-edit-profile/dashboard-edit-profile-page.js @@ -4,6 +4,7 @@ import _ from 'lodash'; import API from 'lib-app/api-call'; import i18n from 'lib-app/i18n'; +import { getCustomFieldParamName } from 'lib-core/APIUtils'; import SessionActions from 'actions/session-actions'; import AreYouSure from 'app-components/are-you-sure'; @@ -42,15 +43,6 @@ class DashboardEditProfilePage extends React.Component { return (
-
{i18n('ADDITIONAL_FIELDS')}
-
this.setState({customFieldsFrom: form})} onSubmit={this.onCustomFieldsSubmit.bind(this)}> -
- {this.state.customFields.map(this.renderCustomField.bind(this))} -
-
- {i18n('SAVE')} -
-
{i18n('EDIT_EMAIL')}
@@ -65,6 +57,23 @@ class DashboardEditProfilePage extends React.Component { {i18n('CHANGE_PASSWORD')} {this.renderMessagePass()} + {this.state.customFields.length ? this.renderCustomFields() : null} +
+ ); + } + + renderCustomFields() { + return ( +
+
{i18n('ADDITIONAL_FIELDS')}
+
this.setState({customFieldsFrom: form})} onSubmit={this.onCustomFieldsSubmit.bind(this)}> +
+ {this.state.customFields.map(this.renderCustomField.bind(this))} +
+
+ {i18n('SAVE')} +
+
); } @@ -116,9 +125,9 @@ class DashboardEditProfilePage extends React.Component { customFields.forEach(customField => { if(customField.type === 'select') { - parsedFrom[`customfield_${customField.name}`] = customField.options[form[customField.name]].name; + parsedFrom[getCustomFieldParamName(customField.name)] = customField.options[form[customField.name]].name; } else { - parsedFrom[`customfield_${customField.name}`] = form[customField.name]; + parsedFrom[getCustomFieldParamName(customField.name)] = form[customField.name]; } }); diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js index f331f06d..361dcb00 100644 --- a/client/src/data/languages/en.js +++ b/client/src/data/languages/en.js @@ -204,7 +204,7 @@ export default { 'IMAGE_HEADER_URL': 'Image header URL', 'IMAGE_HEADER_DESCRIPTION': 'Image that will be used as header of the email', 'EMAIL_SETTINGS': 'Email Settings', - 'ADDITIONAL_FIELDS': 'Additonal Fields', + 'ADDITIONAL_FIELDS': 'Edit additonal fields', 'NEW_CUSTOM_FIELD': 'New Custom field', 'TYPE': 'Type', 'SELECT_INPUT': 'Select input', @@ -326,7 +326,7 @@ export default { 'REGISTRATION_ENABLED': 'Registration has been enabled', 'ADD_API_KEY_DESCRIPTION': 'Insert the name and a registration api key will be generated.', 'SIGN_UP_VIEW_DESCRIPTION': 'Here you can create an account for our support center. It is required to send tickets and see documentation.', - 'EDIT_PROFILE_VIEW_DESCRIPTION': 'Here you can edit your user by changing your email or your password.', + 'EDIT_PROFILE_VIEW_DESCRIPTION': 'Here you can edit your user preferences.', 'ENABLE_USER_SYSTEM_DESCRIPTION': 'Enable/disable the use of an user system. If you disable it, all users will be deleted but the tickets will be kept. If you enable it, the users of existent tickets will be created.', 'CSV_DESCRIPTION': 'The CSV file must have 3 columns: email, password, name. There is no limit in row count. It will be created one user per row in the file.', 'SMTP_SERVER_DESCRIPTION': 'The configuration of the SMTP server allows the application to send mails. If you do not configure it, no emails will be sent by OpenSupports.', diff --git a/client/src/lib-core/APIUtils.js b/client/src/lib-core/APIUtils.js index c9c544f5..d8ca183e 100644 --- a/client/src/lib-core/APIUtils.js +++ b/client/src/lib-core/APIUtils.js @@ -44,4 +44,8 @@ const APIUtils = { } }; +export const getCustomFieldParamName = function (customFieldName) { + return `customfield_${customFieldName}`.replace(/ /g,'_'); +} + export default APIUtils; diff --git a/server/libs/Controller.php b/server/libs/Controller.php index e8c61ff2..04711b5f 100755 --- a/server/libs/Controller.php +++ b/server/libs/Controller.php @@ -152,9 +152,8 @@ abstract class Controller { public static function getCustomFieldValues() { $customFields = Customfield::getAll(); $customFieldValues = new DataStoreList(); - foreach($customFields as $customField) { - $value = Controller::request('customfield_' . $customField->name); + $value = Controller::request('customfield_' . str_replace(' ', '_', $customField->name)); if($value !== null) { $customFieldValue = new Customfieldvalue(); $customFieldValue->setProperties([ @@ -183,7 +182,6 @@ abstract class Controller { $customFieldValues->add($customFieldValue); } } - return $customFieldValues; } } From 38c6295a7b8a95093d8d9e78dd33c11c36dea69e Mon Sep 17 00:00:00 2001 From: LautaroCesso <59095036+LautaroCesso@users.noreply.github.com> Date: Fri, 27 Dec 2019 14:46:33 -0300 Subject: [PATCH 05/11] Improved the render in MainSignUpWidget (Issue #576). (#683) * replace spaces for underscores in edit custom fields * Create function getCustomFieldParamName * Improved the render in MainSignUpWidget --- client/src/app/main/main-signup/main-signup-widget.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/src/app/main/main-signup/main-signup-widget.js b/client/src/app/main/main-signup/main-signup-widget.js index b0a77964..bfe390fe 100644 --- a/client/src/app/main/main-signup/main-signup-widget.js +++ b/client/src/app/main/main-signup/main-signup-widget.js @@ -26,7 +26,7 @@ class MainSignUpWidget extends React.Component { this.state = { loading: false, email: null, - customFields: [] + customFields: null }; } @@ -39,6 +39,7 @@ class MainSignUpWidget extends React.Component { } render() { + if(!this.state.customFields) return null; return (
From d5f5d988fb2acf0c09c2445b99485129f3ab9c79 Mon Sep 17 00:00:00 2001 From: Guillermo Date: Fri, 27 Dec 2019 22:07:40 -0300 Subject: [PATCH 06/11] redirect after deleting ticket --- client/src/app-components/ticket-viewer.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/client/src/app-components/ticket-viewer.js b/client/src/app-components/ticket-viewer.js index 09e1fbad..18dcfee8 100644 --- a/client/src/app-components/ticket-viewer.js +++ b/client/src/app-components/ticket-viewer.js @@ -8,6 +8,7 @@ import i18n from 'lib-app/i18n'; import API from 'lib-app/api-call'; import SessionStore from 'lib-app/session-store'; import MentionsParser from 'lib-app/mentions-parser'; +import history from 'lib-app/history'; import TicketEvent from 'app-components/ticket-event'; import AreYouSure from 'app-components/are-you-sure'; @@ -69,7 +70,6 @@ class TicketViewer extends React.Component { render() { const ticket = this.props.ticket; - return (
@@ -416,7 +416,10 @@ class TicketViewer extends React.Component { data: { ticketNumber: this.props.ticket.ticketNumber } - }).then(this.onTicketModification.bind(this)); + }).then((result) => { + this.onTicketModification(result); + history.push('/admin/panel/tickets/my-tickets/'); + }); } changeDepartment(index) { @@ -444,6 +447,7 @@ class TicketViewer extends React.Component { } }).then(this.onTicketModification.bind(this)); } + addTag(tag) { API.call({ path: '/ticket/add-tag', @@ -463,6 +467,7 @@ class TicketViewer extends React.Component { } }).then(this.onTicketModification.bind(this)) } + onCustomResponsesChanged({index}) { let replaceContentWithCustomResponse = () => { this.setState({ @@ -492,7 +497,7 @@ class TicketViewer extends React.Component { const data = {}; if(ticketeventid){ - data.ticketeventId = ticketeventid + data.ticketEventId = ticketeventid }else{ data.ticketNumber = this.props.ticket.ticketNumber } @@ -523,6 +528,7 @@ class TicketViewer extends React.Component { commentError: true }); } + onSubmit(formState) { this.setState({ loading: true @@ -602,6 +608,7 @@ class TicketViewer extends React.Component { } export default connect((store) => { + return { userId: store.session.userId, userStaff: store.session.staff, From 97d6bd6a36a47a3a5203c4ac30b0d3f615034b68 Mon Sep 17 00:00:00 2001 From: Guillermo Date: Thu, 2 Jan 2020 10:09:44 -0300 Subject: [PATCH 07/11] fix ticket search path showing --- .../src/app/admin/panel/tickets/admin-panel-search-tickets.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/app/admin/panel/tickets/admin-panel-search-tickets.js b/client/src/app/admin/panel/tickets/admin-panel-search-tickets.js index 2dd4f530..f5726f2c 100644 --- a/client/src/app/admin/panel/tickets/admin-panel-search-tickets.js +++ b/client/src/app/admin/panel/tickets/admin-panel-search-tickets.js @@ -20,7 +20,7 @@ class AdminPanelSearchTickets extends React.Component { } getFilters() { - let customList = window.customTicketList[this.props.location.query.custom*1] ? window.customTicketList[this.props.location.query.custom*1] : null + let customList = (window.customTicketList && window.customTicketList[this.props.location.query.custom*1]) ? window.customTicketList[this.props.location.query.custom*1] : null return { ...customList }; From 51e498f8c98048dfb7c8a38d91e112b6e13e5b68 Mon Sep 17 00:00:00 2001 From: Ivan Diaz Date: Tue, 7 Jan 2020 14:44:18 -0300 Subject: [PATCH 08/11] Fix add-api-key description comment --- server/controllers/system/add-api-key.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/controllers/system/add-api-key.php b/server/controllers/system/add-api-key.php index 5f922817..fbb34107 100755 --- a/server/controllers/system/add-api-key.php +++ b/server/controllers/system/add-api-key.php @@ -14,7 +14,7 @@ use Respect\Validation\Validator as DataValidator; * @apiPermission staff3 * * @apiParam {String} name Name of the new APIKey. - * @apiParam {String} type Type of APIKey: "REGSITRATION" or "TICKET_CREATE" + * @apiParam {String} type Type of APIKey: "REGISTRATION" or "TICKET_CREATE" * * @apiUse NO_PERMISSION * @apiUse INVALID_NAME From ec98767e25468f22c7c4cf6d5736d6f6c4f89ec9 Mon Sep 17 00:00:00 2001 From: Ivan Diaz Date: Tue, 7 Jan 2020 14:44:18 -0300 Subject: [PATCH 09/11] Fix APIkey mock --- server/controllers/system/add-api-key.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/controllers/system/add-api-key.php b/server/controllers/system/add-api-key.php index 5f922817..fbb34107 100755 --- a/server/controllers/system/add-api-key.php +++ b/server/controllers/system/add-api-key.php @@ -14,7 +14,7 @@ use Respect\Validation\Validator as DataValidator; * @apiPermission staff3 * * @apiParam {String} name Name of the new APIKey. - * @apiParam {String} type Type of APIKey: "REGSITRATION" or "TICKET_CREATE" + * @apiParam {String} type Type of APIKey: "REGISTRATION" or "TICKET_CREATE" * * @apiUse NO_PERMISSION * @apiUse INVALID_NAME From 9ca6632ee9ce234d5656a83bc275bc3adefa6379 Mon Sep 17 00:00:00 2001 From: Ivan Diaz Date: Tue, 7 Jan 2020 15:09:06 -0300 Subject: [PATCH 10/11] Fix APIKey mock --- server/tests/__mocks__/APIKeyMock.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/tests/__mocks__/APIKeyMock.php b/server/tests/__mocks__/APIKeyMock.php index 7ef32d77..70f5d0d8 100755 --- a/server/tests/__mocks__/APIKeyMock.php +++ b/server/tests/__mocks__/APIKeyMock.php @@ -2,6 +2,10 @@ include_once 'tests/__mocks__/NullDataStoreMock.php'; class APIKey extends \Mock { + const REGISTRATION = 'REGISTRATION'; + const TICKET_CREATE = 'TICKET_CREATE'; + const TYPES = [APIKey::REGISTRATION, APIKey::TICKET_CREATE]; + public static $functionList = array(); public static function initStubs() { From 7b608a6d06421f06767ff682e69c74c6fc756f76 Mon Sep 17 00:00:00 2001 From: Ivan Diaz Date: Tue, 7 Jan 2020 17:29:28 -0300 Subject: [PATCH 11/11] Fix disable-user-system test --- tests/system/disable-user-system.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/disable-user-system.rb b/tests/system/disable-user-system.rb index 05a2e10d..7107ecc3 100644 --- a/tests/system/disable-user-system.rb +++ b/tests/system/disable-user-system.rb @@ -220,7 +220,7 @@ describe'system/disable-user-system' do numberOftickets= $database.query("SELECT * FROM ticket WHERE author_email IS NULL AND author_name IS NULL AND author_id IS NOT NULL" ) - (numberOftickets.num_rows).should.equal(53) + (numberOftickets.num_rows).should.equal(54) end it 'should not enable the user system' do