Merged in bugfix/PMCORE-3465 (pull request #8326)

PMCORE-3465

Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
Andrea Adamczyk
2021-12-15 21:22:53 +00:00
committed by Julio Cesar Laura Avendaño
5 changed files with 22 additions and 18 deletions

View File

@@ -1,6 +1,9 @@
import _ from "lodash";
import axios from "axios";
import { RCBase64 } from '../utils/utils.js'
var base64 = RCBase64();
const urlBase = "{server}/api/1.0/{workspace}{service}";
var credentials = JSON.parse(base64.decode(window.config.SYS_CREDENTIALS));
class Api {
constructor(services) {
this.services = services;
@@ -39,7 +42,6 @@ class Api {
data = options.data || {},
keys = options.keys || {},
url,
credentials = window.config.SYS_CREDENTIALS,
workspace = window.config.SYS_WORKSPACE,
server = window.config.SYS_SERVER_API,
lang = window.config.SYS_LANG,
@@ -63,7 +65,6 @@ class Api {
params = options.params || {},
keys = options.keys || {},
url,
credentials = window.config.SYS_CREDENTIALS,
workspace = window.config.SYS_WORKSPACE,
lang = window.config.SYS_LANG,
server = window.config.SYS_SERVER_API;
@@ -88,7 +89,6 @@ class Api {
keys = options.keys || {},
headers = options.headers || {},
url,
credentials = window.config.SYS_CREDENTIALS,
workspace = window.config.SYS_WORKSPACE,
lang = window.config.SYS_LANG,
server = window.config.SYS_SERVER_API;
@@ -115,7 +115,6 @@ class Api {
keys = options.keys || {},
headers = options.headers || {},
url,
credentials = window.config.SYS_CREDENTIALS,
workspace = window.config.SYS_WORKSPACE,
server = window.config.SYS_SERVER_API;
url = this.getUrl(_.extend(keys, credentials, { server }, { workspace }), service);
@@ -137,7 +136,6 @@ class Api {
id = options.id || {},
keys = options.keys || {},
url,
credentials = window.config.SYS_CREDENTIALS,
workspace = window.config.SYS_WORKSPACE,
lang = window.config.SYS_LANG,
server = window.config.SYS_SERVER_API;
@@ -161,7 +159,6 @@ class Api {
id = options.id || {},
keys = options.keys || {},
url,
credentials = window.config.SYS_CREDENTIALS,
workspace = window.config.SYS_WORKSPACE,
lang = window.config.SYS_LANG,
server = window.config.SYS_SERVER_API;
@@ -191,7 +188,6 @@ class Api {
data = options.data || {},
keys = options.keys || {},
url,
credentials = window.config.SYS_CREDENTIALS,
workspace = window.config.SYS_WORKSPACE,
lang = window.config.SYS_LANG,
server = window.config.SYS_SERVER_API;

View File

@@ -1,8 +1,10 @@
import axios from "axios";
import ApiInstance from "./Api.js";
import Services from "./Services";
import { RCBase64 } from '../utils/utils.js'
let Api = new ApiInstance( Services );
var base64 = RCBase64();
var credentials = JSON.parse(base64.decode(window.config.SYS_CREDENTIALS));
export let cases = {
myCases(data) {
return Api.get({
@@ -148,7 +150,7 @@ export let cases = {
window.config.SYS_WORKSPACE +
'/home/' + data.APP_NUMBER + '/pending-tasks', {
headers: {
'Authorization': 'Bearer ' + window.config.SYS_CREDENTIALS.accessToken,
'Authorization': 'Bearer ' + credentials.accessToken,
"Accept-Language": window.config.SYS_LANG
}
});
@@ -355,7 +357,7 @@ export let casesHeader = {
window.config.SYS_WORKSPACE +
'/home/counters', {
headers: {
'Authorization': 'Bearer ' + window.config.SYS_CREDENTIALS.accessToken,
'Authorization': 'Bearer ' + credentials.accessToken,
"Accept-Language": window.config.SYS_LANG
}
});

View File

@@ -1,5 +1,7 @@
import axios from 'axios';
import { RCBase64 } from '../utils/utils.js'
var base64 = RCBase64();
var credentials = JSON.parse(base64.decode(window.config.SYS_CREDENTIALS));
export let menu = {
get() {
return axios.get(
@@ -8,7 +10,7 @@ export let menu = {
window.config.SYS_WORKSPACE +
'/home/menu', {
headers: {
'Authorization': 'Bearer ' + window.config.SYS_CREDENTIALS.accessToken,
'Authorization': 'Bearer ' + credentials.accessToken,
"Accept-Language": window.config.SYS_LANG
}
});
@@ -21,7 +23,7 @@ export let menu = {
window.config.SYS_WORKSPACE +
'/home/tasks/counter', {
headers: {
'Authorization': 'Bearer ' + window.config.SYS_CREDENTIALS.accessToken,
'Authorization': 'Bearer ' + credentials.accessToken,
"Accept-Language": window.config.SYS_LANG
}
});
@@ -38,7 +40,7 @@ export let menu = {
window.config.SYS_WORKSPACE +
'/home/'+ task +'/counter', {
headers: {
'Authorization': 'Bearer ' + window.config.SYS_CREDENTIALS.accessToken,
'Authorization': 'Bearer ' + credentials.accessToken,
"Accept-Language": window.config.SYS_LANG
}
});
@@ -55,7 +57,7 @@ export let menu = {
window.config.SYS_WORKSPACE +
'/home/' + data.page + '/counter/caseList/' + data.id, {
headers: {
'Authorization': 'Bearer ' + window.config.SYS_CREDENTIALS.accessToken,
'Authorization': 'Bearer ' + credentials.accessToken,
"Accept-Language": window.config.SYS_LANG
}
}
@@ -72,7 +74,7 @@ export let menu = {
window.config.SYS_WORKSPACE +
'/home/tasks/highlight', {
headers: {
'Authorization': 'Bearer ' + window.config.SYS_CREDENTIALS.accessToken,
'Authorization': 'Bearer ' + credentials.accessToken,
"Accept-Language": window.config.SYS_LANG
}
});

View File

@@ -91,3 +91,7 @@ export default {
return obj;
}
}
export function RCBase64() {
var RCBase64 = { keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", encode: function (e) { var t, r, s, o, i, n, a, h = "", c = 0; for (e = this.utf8_encode(e); c < e.length;)t = e.charCodeAt(c++), r = e.charCodeAt(c++), s = e.charCodeAt(c++), o = t >> 2, i = (3 & t) << 4 | r >> 4, n = (15 & r) << 2 | s >> 6, a = 63 & s, isNaN(r) ? n = a = 64 : isNaN(s) && (a = 64), h = h + this.keyStr.charAt(o) + this.keyStr.charAt(i) + this.keyStr.charAt(n) + this.keyStr.charAt(a); return h }, decode: function (e) { var t, r, s, o, i, n, a, h = "", c = 0; for (e = e.replace(/[^A-Za-z0-9\+\/\=]/g, ""); c < e.length;)o = this.keyStr.indexOf(e.charAt(c++)), i = this.keyStr.indexOf(e.charAt(c++)), n = this.keyStr.indexOf(e.charAt(c++)), a = this.keyStr.indexOf(e.charAt(c++)), t = o << 2 | i >> 4, r = (15 & i) << 4 | n >> 2, s = (3 & n) << 6 | a, h += String.fromCharCode(t), 64 !== n && (h += String.fromCharCode(r)), 64 !== a && (h += String.fromCharCode(s)); return h = this.utf8_decode(h) }, utf8_encode: function (e) { e = e.replace(/\r\n/g, "\n"); var t, r, s = ""; for (t = 0; t < e.length; t++)r = e.charCodeAt(t), 128 > r ? s += String.fromCharCode(r) : r > 127 && 2048 > r ? (s += String.fromCharCode(r >> 6 | 192), s += String.fromCharCode(63 & r | 128)) : (s += String.fromCharCode(r >> 12 | 224), s += String.fromCharCode(r >> 6 & 63 | 128), s += String.fromCharCode(63 & r | 128)); return s }, utf8_decode: function (e) { for (var t = "", r = 0, s = 0, o = 0, i = 0; r < e.length;)s = e.charCodeAt(r), 128 > s ? (t += String.fromCharCode(s), r++) : s > 191 && 224 > s ? (o = e.charCodeAt(r + 1), t += String.fromCharCode((31 & s) << 6 | 63 & o), r += 2) : (o = e.charCodeAt(r + 1), i = e.charCodeAt(r + 2), t += String.fromCharCode((15 & s) << 12 | (63 & o) << 6 | 63 & i), r += 3); return t } };
return RCBase64;
}

View File

@@ -149,7 +149,7 @@ global $translation;
$pmDynaform = new PmDynaform();
ScriptVariables::add('defaultOption', $defaultOption);
ScriptVariables::add('_nodeId', isset($confDefaultOption) ? $confDefaultOption : "PM_USERS");
ScriptVariables::add('SYS_CREDENTIALS', $pmDynaform->getCredentials());
ScriptVariables::add('SYS_CREDENTIALS', base64_encode(G::json_encode($pmDynaform->getCredentials())));
ScriptVariables::add('SYS_SERVER_API', System::getHttpServerHostnameRequestsFrontEnd());
ScriptVariables::add('SYS_SERVER_AJAX', System::getServerProtocolHost());
ScriptVariables::add('SYS_WORKSPACE', config("system.workspace"));